---
title: 'How to install NextCloud on Docker | Zomro'
description: 'NextCloud is a popular open source file sharing and collaboration platform that lets you store, share, and collaborate on documents, photos, videos, and more.'
image: 'https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676899478_01.png'
---

![opened image]()

  * [Zomro](https://zomro.com/)
  * [FAQ](https://zomro.com/blog/faq/)
  * How to install NextCloud on Docker 



# How to install NextCloud on Docker

26-02-2023

NextCloud is a popular open source file sharing and collaboration platform that lets you store, share, and collaborate on documents, photos, videos, and more.  
  
In this article, we will walk you through the process of installing NextCloud in Docker Compose.  


## **Installing Docker and Docker Compose**

Before you get started, you need to install Docker and Docker Compose. You can find installation instructions for your operating system on our blog for Centos 7 or Ubuntu 20.04.  
  


## **Install Docker Compose**
    
    
    curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin /docker-compose

  
Set permissions to launch.
    
    
    chmod +x /usr/local/bin/docker-compose
    

  
Check how Docker-Compose was installed:
    
    
    docker-compose --version
    

  
![How to install NextCloud on Docker - 1](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676899478_01.png)

### **Create a directory to store your Nextcloud data**

  
This directory will store user data and files. For example, you can create the**/opt/nextcloud-data** directory and change to:
    
    
    mkdir /opt/nextcloud-data && cd /opt/nextcloud-data
    

## **Create a Docker Compose File**

  
Next, you need to create a Docker Compose file that defines the services for NextCloud. To create the file, open a text editor and create a new file called **docker-compose.yml**. Copy and paste the following code into a file:
    
    
    version: '3'
    
    services:
      nextcloud_db:
        image: mariadb:10.5
        command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
        restart: always
        volumes:
          - ./nextcloud-db:/var/lib/mysql
        environment:
          - MYSQL_ROOT_PASSWORD=vAfrhiwaj7spoe1DBARv
          - MYSQL_PASSWORD=22CifgJLFFdeKKuprzT6
          - MYSQL_DATABASE=nextcloud
          - MYSQL_USER=nextcloud
    
      nextcloud:
        image: nextcloud
        ports:
          - 9090:80
        links:
          - nextcloud_db
        volumes:
          - ./nextcloud:/var/www/html
        environment:
          - NEXTCLOUD_DATA_DIR=/var/www/html/data
          - MYSQL_PASSWORD=22CifgJLFFdeKKuprzT6
          - MYSQL_DATABASE=nextcloud
          - MYSQL_USER=nextcloud
          - MYSQL_HOST=nextcloud_db
        restart: always
    

  
  
After saving the file, run the following command in the folder where the **yaml** file is located:
    
    
    docker-compose up -d
    

  
  
And we can observe the deployment of containers.  
  
![How to install NextCloud on Docker - 2](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676900326_1.png)  
![How to install NextCloud on Docker - 3](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676900332_2.png)  
After successful deployment, the containers will be launched.  
  
![How to install NextCloud on Docker - 4](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676900362_3.png)  
Let's consider the Docker Compose configuration file for running two containers: MariaDB database and Nextcloud web application.  
  
In the first section, we define the nextcloud_db service, which will represent the MariaDB database. For this service, we use the official Docker image **mariadb:10.5.**  
  
**Then we set several parameters:**

  * **command** : This parameter sets the command that will be run inside the container. Here we set the parameters for MariaDB to use **READ** -**COMMITTED** as the transaction isolation level and******ROW** as the binary log format.
  * **restart** : This parameter specifies that the container should be automatically restarted in case of a failure.
  * **volumes** : This parameter mounts the local directory **./nextcloud-db** inside the container at the path**/var/lib/mysql**. This allows for saving the database data on the local disk.



  
**Then we set environment variables:**

  * **MYSQL_ROOT_PASSWORD** : This is the password for the MariaDB database superuser (root).
  * **MYSQL_PASSWORD** : This is the password for the nextcloud database user.
  * **MYSQL_DATABASE** : This is the name of the database that will be created for Nextcloud.
  * **MYSQL_USER** : This is the name of the user that will be created for the Nextcloud database.



  
In the second section, we define the **nextcloud** service, which will represent the Nextcloud web application. For this service, we use the official Docker image **nextcloud**.  
  
**Then we set several parameters:**

  * **ports** : This parameter maps port **9090** on the local machine to port **80** inside the container. This allows for accessing Nextcloud from a web browser.
  * **links** : This parameter links the container to the MariaDB database so that Nextcloud can use it to store data.
  * **volumes** : This parameter mounts the local directory **./nextcloud** inside the container at the path **/var/www/html.** This allows for saving the application data on the local disk.



  
**Then we set environment variables:**

  * **NEXTCLOUD_DATA_DIR** : This is the path where Nextcloud will store data.
  * **MYSQL_PASSWORD** : This is the password for the nextcloud database user.
  * **MYSQL_DATABASE** : This is the name of the database created for Nextcloud.
  * **MYSQL_USER** : This is the name of the user created for the Nextcloud database.
  * **MYSQL_HOST** : This parameter specifies the database host name that the Nextcloud application should connect to.



  
Finally, we set the **restart** parameter to automatically restart the Nextcloud container in case of a failure.  
  
  
Now in the browser line, write the IP of your server and the port that you set. In our case, this is 9090.
    
    
    http://192.168.0.100:9090
    

  
![How to install NextCloud on Docker - 5](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676899949_03.png)  
  
Now we can log in. Enter your username and password in the field. They will be created when you enter the panel.  
  
![How to install NextCloud on Docker - 6](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676901200_6.png)  
After authorization, we can observe the welcome window.  
  
![How to install NextCloud on Docker - 7](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676900196_7.png)  
Overall, this Docker Compose configuration allows for easily running Nextcloud with a MariaDB database that stores data on the local disk. Thanks to this, you can easily deploy Nextcloud on your local machine or server to use it for storing files, calendars, and so on.

We also suggest you other useful articles:

  * [List of important commands for working with Docker-compose](https://zomro.com/blog/faq/304-spisok-vazhnyh-komand-dlja-raboty-s-docker-compose)
  * [Dockerfile: A Complete Guide for Beginners and Professionals](https://zomro.com/blog/faq/477-dockerfile-a-complete-guide-for-beginners-and-professionals)
  * [How to copy data from a host to Docker and from Docker to a host](https://zomro.com/blog/faq/284-kak-skopirovat-dannye-s-hosta-v-docker-i-iz-docker-na-host)



Similar articles:

[How to install MariaDB 10.8 on CentOS 7 or upgrade from mysql 5.7](https://zomro.com/blog/faq/255-kak-ustanovit-mariadb-108-v-centos-7-ili-sdelat-upgrade-s-mysql-57) [How to allow images larger than 2560 pixels to be uploaded in WordPress](https://zomro.com/blog/faq/362-how-to-allow-images-larger-than-2560-pixels-to-be-uploaded-in-wordpress) [How to install an SSL certificate on Windows Server](https://zomro.com/blog/faq/278-kak-ustanovit-ssl-sertifikat-v-windows-server) [How to install PostgreSQL and pgAdmin in Docker](https://zomro.com/blog/faq/283-kak-ustanovit-postgresql-i-pgadmin-v-docker) [How to install Nginx in Docker-Compose](https://zomro.com/blog/faq/317-kak-ustanovit-nginx-v-docker-compose)

[ Premium Cloud VPS from €7.95/mon ](/premium-vps)
