Nextcloud is a powerful open-source software for file synchronization and sharing that gives you full control over your data.
Let's get started right away.
Prerequisites
Before we begin, make sure the following prerequisites are met:
- Docker is installed on your server
- Docker Compose is installed
- Sufficient storage space is available for Nextcloud and the data to be stored later
Setting up Nextcloud with Docker Compose
First, create an empty directory on your server and create a file named docker-compose.yml inside it.
Then insert the following content:
version: '3' # YAML version
services:
db: # Database service
image: mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: always
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=my-secret-pw
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_PASSWORD=my-secret-pw
app: # Nextcloud application
image: nextcloud
restart: always
volumes:
- nextcloud:/var/www/html
environment:
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_PASSWORD=my-secret-pw
- MYSQL_HOST=db
volumes:
db:
nextcloud:
Explanation
This docker-compose.yml defines two services:
db A MariaDB database for Nextcloud
app The actual Nextcloud container
Be sure to adjust the passwords (my-secret-pw) to meet your security requirements.
Starting the Nextcloud container
In the terminal, navigate to the directory containing your docker-compose.yml and start the containers with:
docker-compose up -d
Docker Compose will now download the required images and start the containers. This may take a few minutes.
Setting up Nextcloud in the browser
Once the containers are running:
- Open a web browser
- Navigate to the IP address or domain name of your server (default port 80)
- The Nextcloud setup wizard will appear
Follow the wizard:
- Create an admin user
- Database type: MySQL / MariaDB
- Database name:
nextcloud - User:
nextcloud - Password: the password set in the
docker-compose.yml - Host:
db
After completing the setup, your Nextcloud instance is ready to use.
Done. 🎉 Your Nextcloud is now running cleanly in Docker – without a proxy, neat and maintainable.