Install Nextcloud on Docker

by RamWise
Published: Last Updated on 5.5K views

Nextcloud is a free self-hosted personal cloud solution like Dropbox. It can also manage calendars, Contacts, Mail, and do Video Conferencing too. It is an excellent self-hosted Dropbox or Google drive alternative. Nextcloud can be installed on Docker as a container, or as a stand-alone application as well. In this tutorial, we will see how to install the Nextcloud server on Docker.

Nextcloud Docker container

Make sure you have installed Portainer & Docker before proceeding. We will add a docker stack of Nextcloud with MariaDB (as a data store).

1. On Portainer, add a new stack with name Nextcloud. Leave the Build method as Web Editor.

2. Copy the below compose file content into the Web editor. Do not deploy the stack yet, I’ll explain what some important configurations do in the following steps. You can customize them if required.

version: '2'

    image: mariadb
    container_name: mariadb
    restart: unless-stopped
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
      - 3306:3306
      - /opt/container/mariadb:/var/lib/mysql
      - MYSQL_ROOT_PASSWORD=changeme  
      - MYSQL_PASSWORD=changeme
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - bridge

    image: nextcloud
    container_name: nextcloud
    restart: always
      - 8080:80
      - /opt/container/nextcloud:/var/www/html
      - MYSQL_PASSWORD=changeme
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=mariadb
      - bridge 

MariaDB Database container

3. We will configure a DB store in MariaDB for Nextcloud to use. Start with setting the listening port (default:3306) for the container. This can be mapped onto a different host port as well.

4. Set a storage location for MariaDB application data. I am mapping a local folder to the container directory.

5. Add a root password for MySQL. You’ll use this for DB administration.

6. Create a user and database for Nextcloud to use. We will use these details again in Nextcloud settings.

Nextcloud container

7. The default Container port for Nextcloud web UI is 80, and I am mapping it to the host port 8080 here. 

8. After that add a file storage location for Nextcloud. This is where the web and user files are stored.

9. Next, add the db host name and user credentials we entered earlier in MariaDB. Once done deploy the stack and start the containers.

10. To finish the setup go to http://localhost:8080 on your web browser, and create an admin account. It will create all the required DB tables and other data.

11. Once the first time setup process is completed successfully, you will reach the home screen. You can add more users from here by going to the settings menu.

That is it, now you can start using your Nextcloud server. You can also connect to your account via mobile apps and desktop sync clients.

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More