Nextcloud Logo

Install Nextcloud with Docker

Nextcloud is a powerful open-source platform for your own private cloud — file hosting, calendars, contacts, and much more. The recommended installation method is Docker Compose, as it neatly encapsulates all required services in containers.

Prerequisites:
✓ A server running a recent Linux distribution (e.g. Ubuntu 22.04)
Docker and Docker Compose installed on the server
✓ A domain name pointing to your server's IP address (recommended for SSL)

Step 1: Create the Docker Compose File

Log in to your server via SSH, create a directory for Nextcloud, and open the Compose file:

Create Directory and File
mkdir nextcloud && cd nextcloud && nano docker-compose.yml

Paste the following content into the file. Replace the password placeholders with your own secure values — more on this in Step 2.

docker-compose.yml
version: '3' services: db: image: mariadb:10.6 restart: always command: --transaction-isolation=READ-COMMITTED --log-transaction-warnings=0 volumes: - ./db:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=YOUR_STRONG_ROOT_PASSWORD - MYSQL_PASSWORD=YOUR_STRONG_MYSQL_PASSWORD - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud app: image: nextcloud:latest restart: always ports: - 8080:80 links: - db volumes: - ./nextcloud:/var/www/html environment: - MYSQL_PASSWORD=YOUR_STRONG_MYSQL_PASSWORD - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud - MYSQL_HOST=db

Step 2: Set Your Passwords

Before proceeding, replace both placeholders in the file with your own secure passwords:

PlaceholderDescription
YOUR_STRONG_ROOT_PASSWORDRoot password for MariaDB — used internally only
YOUR_STRONG_MYSQL_PASSWORDPassword for the Nextcloud database user — must be identical in both db and app

The MYSQL_PASSWORD must be exactly the same in both the db and app services — otherwise Nextcloud will not be able to connect to the database.

Step 3: Start the Stack

Start the entire Nextcloud stack with a single command. Docker will pull the required images and start all containers in the background.

Start Docker Compose
docker compose up -d

The -d flag stands for "detached mode" — the containers run in the background without blocking your terminal session.

Step 4: Complete Setup in the Browser

Once the containers are running, Nextcloud is accessible in your browser. Open:

http://YOUR_SERVER_IP:8080

1.Create your administrator account by choosing a username and password
2.Under Storage & Database, select MySQL/MariaDB
3.Fill in the database fields with the following values:
FieldValue
Database usernextcloud
Database passwordYOUR_STRONG_MYSQL_PASSWORD
Database namenextcloud
Database hostdb

Click Finish setup. After a few moments you will be logged in to your new Nextcloud instance.

Step 5: Set Up a Reverse Proxy for HTTPS (Recommended)

For a production-ready setup, you should not access Nextcloud permanently via IP address and port 8080. A reverse proxy routes traffic from your domain and enables HTTPS encryption — allowing you to reach Nextcloud securely via an address like https://cloud.yourdomain.com.

Common tools for this are Nginx Proxy Manager, Traefik, or Caddy. All three can also run as Docker containers and integrate well with this setup.

Further Documentation

For detailed configuration options and advanced setup scenarios, we recommend the official Nextcloud documentation.