title: “Setting Up Nextcloud with Docker: A Comprehensive Guide” date: 2023-08-31 draft: false


Nextcloud is a popular open-source cloud storage solution that allows you to host your own cloud storage platform. Beyond its primary function, there are numerous reasons to consider Nextcloud over other cloud storage solutions. In this guide, we’ll delve into the benefits of using Nextcloud and walk you through the process of installing Docker and setting up Nextcloud using Docker Compose.

Why You Should Run Nextcloud

  • Data Ownership and Privacy: In an era where data privacy is paramount, Nextcloud provides full control over your data. Unlike commercial cloud storage solutions, your files reside on your server, ensuring you know exactly where your data is and who accesses it.

  • Cost-Effective: While commercial cloud storage solutions come with recurring fees, Nextcloud is open-source and free. You only pay for the server infrastructure, which can be scaled based on your needs, potentially saving you a significant amount over time.

  • Extensibility: Nextcloud features an app store, allowing you to extend its functionality. From calendar synchronization to contact management or collaborative document editing, there’s likely an app for your needs.

  • Security: Nextcloud offers robust security features, including end-to-end encryption, brute-force protection, and two-factor authentication. Its open-source nature means continuous community scrutiny, leading to timely vulnerability detection and patching.

  • Collaboration: Beyond file storage, Nextcloud provides real-time document collaboration, chat, and video calls, making it a comprehensive tool for teams.

  • Self-hosted: For businesses with specific regulations or strict data residency requirements, Nextcloud’s self-hosting capability ensures data doesn’t cross borders or end up in undesirable jurisdictions.

  • Customization: Being open-source, Nextcloud can be tailored to specific needs, from branding to integration with other tools or adding new features.

  • Community and Support: With a vibrant community and various commercial support options, you’re never alone when facing issues or seeking assistance with Nextcloud.

1. Installing Docker

For Ubuntu:

  1. Update your local package index:
    sudo apt update
2. Install Docker's package dependencies:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
  1. Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  1. Add Docker’s APT repository:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  1. Install docker
sudo apt update
sudo apt install docker-ce

For other operating systems:

Refer to the official Docker documentation.

2. Installing Docker Compose

  1. Download the latest version of Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  1. Make the binary executable:
sudo chmod +x /usr/local/bin/docker-compose

3. Setting Up Nextcloud with Docker Compose

  1. Create a directory for your Nextcloud setup:
mkdir nextcloud-docker && cd nextcloud-docker
  1. Create a docker-compose.yml file:
nano docker-compose.yml
  1. Paste the following configuration into the file:
version: '3'

    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
      - db:/var/lib/mysql
      - MYSQL_ROOT_PASSWORD=my-secret-pw
      - MYSQL_PASSWORD=my-secret-pw
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

    image: nextcloud
      - 8080:80
      - db
      - nextcloud:/var/www/html
    restart: always

  1. Start the Nextcloud instance:
docker-compose up -d
  1. Access Nextcloud by navigating to http://localhost:8080 in your browser. Complete the setup by entering the database details (use the credentials and database name provided in the docker-compose.yml file).


You’ve now successfully set up Nextcloud using Docker Compose, combining the power of self-hosted cloud storage with the flexibility and scalability of containerization. Whether you’re an individual seeking more control over your data or a business with specific operational needs, Nextcloud, when paired with Docker, offers a compelling, secure, and efficient cloud storage solution.