Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A ready-to-use Docker setup for Nextcloud with optional MariaDB support. Includes persistent storage, customizable ports, and admin configuration. Quick start guide for running a fully functional Nextcloud instance via Docker for production or development use.

Notifications You must be signed in to change notification settings

sumaiazaman/nextcloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Nextcloud Docker Deployment

A simple and efficient Docker Compose setup for deploying Nextcloud with MySQL database backend.

📋 Overview

This project provides a ready-to-use Nextcloud instance running in Docker containers. Nextcloud is a self-hosted file sync and collaboration platform that gives you control over your data.

🚀 Features

  • Easy Setup: One-command deployment using Docker Compose
  • Persistent Storage: Data persists across container restarts
  • MySQL Backend: Reliable MySQL 8.1 database
  • Configurable: Environment-based configuration
  • Auto-restart: Containers automatically restart on failure

📦 Prerequisites

Before you begin, ensure you have the following installed:

🛠️ Installation

1. Clone the Repository

  git clone [email protected]:sumaiazaman/nextcloud.git
  cd nextcloud

2. Configure Environment Variables

Create your .env file from the example template:

  cp .env.example .env

Then edit the .env file and change the default passwords:

  nano .env
# or use your preferred editor: vim, code, etc.

Update the following values:

# MySQL Configuration
MYSQL_ROOT_PASSWORD=your_secure_root_password_here
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud_user
MYSQL_PASSWORD=your_secure_password_here

# Nextcloud Configuration
NEXTCLOUD_PORT=8888

Configuration Options:

  • MYSQL_ROOT_PASSWORD: Root password for MySQL (use a strong password)
  • MYSQL_DATABASE: Database name (default: nextcloud)
  • MYSQL_USER: Database user for Nextcloud (default: nextcloud_user)
  • MYSQL_PASSWORD: Password for the database user (use a strong password)
  • NEXTCLOUD_PORT: Port to access Nextcloud web interface (default: 8888)

Security Note:

  • Never commit your .env file with real passwords to version control
  • Use strong, unique passwords for production deployments
  • The .env file is already in .gitignore to prevent accidental commits

3. Start the Services

  docker-compose up -d

This command will:

  • Download the required Docker images (if not already present)
  • Create and start the MySQL and Nextcloud containers
  • Set up persistent volumes for data storage

4. Access Nextcloud

Open your web browser and navigate to:

http://localhost:8888

Or replace localhost with your server's IP address if accessing remotely.

🔧 Initial Setup

On first access, you'll see the Nextcloud setup wizard:

  1. Create Admin Account: Choose a username and strong password

  2. Database Configuration: The database is already configured via environment variables, but if prompted:

    • Database user: nextcloud_user (or your configured MYSQL_USER)
    • Database password: Your MYSQL_PASSWORD
    • Database name: nextcloud
    • Database host: mysql
  3. Click Finish Setup

📂 Project Structure

.
├── docker-compose.yml    # Docker Compose configuration
├── .env.example          # Environment variables template
├── .env                  # Your environment variables (create from .env.example)
└── README.md            # This file

Note: The .env file is not included in the repository for security reasons. You must create it from .env.example.

🔄 Common Operations

View Running Containers

  docker-compose ps

View Logs

# All services
docker-compose logs -f

# Nextcloud only
docker-compose logs -f nextcloud

# MySQL only
docker-compose logs -f mysql

Stop Services

  docker-compose down

Stop and Remove All Data

  docker-compose down -v

Warning: This will delete all your Nextcloud files and database!

Restart Services

  docker-compose restart

Update to Latest Version

  docker-compose pull
  docker-compose up -d

💾 Data Persistence

Data is stored in Docker volumes:

  • nextcloud_data: Nextcloud files and configuration
  • db_data: MySQL database files

These volumes persist even when containers are stopped or removed (unless you use docker-compose down -v).

🔒 Security Recommendations

  1. Change Default Passwords: Update all passwords in .env before deployment
  2. Use HTTPS: Consider setting up a reverse proxy (nginx/Traefik) with SSL certificates
  3. Firewall: Restrict access to the Nextcloud port
  4. Regular Backups: Backup your volumes regularly
  5. Keep Updated: Regularly update Docker images for security patches

🐛 Troubleshooting

Cannot Access Nextcloud

  • Check if containers are running: docker-compose ps
  • Verify port is not in use: netstat -tuln | grep 8888
  • Check logs: docker-compose logs nextcloud

Database Connection Error

  • Ensure MySQL container is healthy: docker-compose ps
  • Verify environment variables match in both services
  • Check MySQL logs: docker-compose logs mysql

Permission Issues

  docker-compose exec nextcloud chown -R www-data:www-data /var/www/html

📝 License

This project is open source and available under the MIT License.

🤝 Contributing

Contributions, issues, and feature requests are welcome!

📧 Support

For Nextcloud-specific issues, visit the official documentation.


Note: This is a basic setup suitable for personal use or small teams. For production environments, consider additional security measures, SSL/TLS encryption, and regular backups.

About

A ready-to-use Docker setup for Nextcloud with optional MariaDB support. Includes persistent storage, customizable ports, and admin configuration. Quick start guide for running a fully functional Nextcloud instance via Docker for production or development use.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published