How to install Nextcloud with Docker

Nextcloud Logo

Nextcloud is a powerful, open-source platform that allows you to create your own private cloud for file hosting, calendars, contacts, and much more. The most reliable and recommended method for installing Nextcloud is by using Docker and Docker Compose. This approach encapsulates all the required services (web server, database, etc.) into manageable containers.


Prerequisites:
  • A server running a modern Linux distribution (e.g., Ubuntu 22.04).
  • Docker and Docker Compose installed on your server. You can find the official guide here: Install Docker Engine on Ubuntu.
  • A domain name pointing to your server's IP address (recommended for a production setup with SSL).

Installation Steps

First, log into your server via SSH. Create a directory for your Nextcloud project and then create the docker-compose.yml file within it.

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

Paste the following content into the docker-compose.yml file:

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