NextCloud on Synology NAS using Docker compose (with Portainer)

Docker NextCloud on Synology NAS using Docker compose (with Portainer)


In this tutorial, we are going to use Docker compose to install the NextCloud official Docker image with Portainer.

To start​

This is going to be just one of many ways to install NextCloud. I am going to show you my way.

First, you need to have Docker installed on your NAS (if it's supported).

Now install Portainer. You can use @Rusty's tutorial: Docker - Portainer - Docker container managment made easy


Now that we have all the required tools, first, install the MariaDB using this tutorial: Docker - MariaDB - one of the most popular database servers

You can also use MySQL or PostgreSQL, but in this tutorial, we are using MariaDB.

For accessing the database I use phpMyAdmin: Docker - phpMyAdmin - A web interface for MySQL and MariaDB

Login to phpMyAdmin and create a database for Nextcloud. Write down your database name, database user, and password. You are going to need this later.


First, make sure to create folders for Nextcloud in your FileStation before you enter the docker-compose code.

I am using this location: docker/nextcloud. and this is on Volume 1:
  • /volume1/docker/nextcloud/html
  • /volume1/docker/nextcloud/custom_apps
  • /volume1/docker/nextcloud/config
  • /volume1/docker/nextcloud/data
  • /volume1/docker/nextcloud/themes

Screenshot 2021-09-16 at 12.11.24.png

Now we are going to use the official image:

Login to your Portainer and create a Stack (read more about how to use stacks here: Docker - Portainer - using stacks (docker-compose)).

Now use this docker-compose:
version: "3.5"
    image: nextcloud:latest
    restart: always
    network_mode: bridge
    container_name: nextcloud
      - 8787:80
      - /volume1/docker/nextcloud/html:/var/www/html
      - /volume1/docker/nextcloud/custom_apps:/var/www/html/custom_apps
      - /volume1/docker/nextcloud/config:/var/www/html/config
      - /volume1/docker/nextcloud/data:/var/www/html/data
      - /volume1/docker/nextcloud/themes:/var/www/html/themes/
      - PUID=1031
      - PGID=1023
      - TZ=London/Europe
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=user_nextcloud
      - MYSQL_PASSWORD=********
      - MYSQL_HOST=

We are using the latest image.

Use NEXTCLOUD_TRUSTED_DOMAINS variable if you are using a custom domain, otherwise, you can remove it.

Use OVERWRITEPROTOCOL=https variable to redirect your domain to HTTPS protocol. If you won't use your custom domain for NextCloud and use it only locally, then you can remove this variable too.

You can change the port if you wish (the left number only).

Make sure to change the PUID and PGID to your http user ID and group (Tutorial - How to find UID (userID) and GID (groupID)?).

Change TZ to your timezone.

The next three variables are for the database. Make sure to use the right credentials.
*Note that I like to have the database separated and not in the same stack, but you can combine it together in one stack.

For host use yourNASip:databaseLocalPort.

Deploy the stack and that should be enough. Open NextCloud on yourNASip:nextcloudPort. Continue with the guided NextCloud installation.

As already said, this can be done in many ways. I hope this way will help someone to install NextCloud.
Related resources

Similar resources

0.00 star(s) 0 ratings
Josh Adams on the Synology Community provides this useful how-to
0.00 star(s) 0 ratings
0.00 star(s) 0 ratings
How to monitor, control, damage check of disks in your Synology NAS jeyare
this resource is useful for all categories Syno NAS users, except I don't care segment
0.00 star(s) 0 ratings
A one-of-a-kind resume builder that keeps your privacy in mind
0.00 star(s) 0 ratings
Migrating existing Ubiquiti UniFi Controller to Docker in Synology NAS jeyare
Migrating existing Ubiquiti UniFi Controller to Docker in Synology NAS
0.00 star(s) 0 ratings
Native macOS Finder integration with Synology Universal Search Robbie
Using macOS Finder's native search engine with a Synology NAS
5.00 star(s) 2 ratings