Synology: How to Install Nextcloud Using Docker

Synology How to Install Nextcloud Using Docker

Nextcloud is a suite of client-server software for creating and using file hosting services. Nextcloud recently changed its name to Nextcloud Hub 7. It’s free and open-source which means that anyone is allowed to install and operate it on their own private server devices. In this step by step guide I will show you how to install Nextcloud Hub 7 on your Synology NAS using Docker & Portainer.

💡Note: This guide works perfectly with the latest Nextcloud Hub 7 28.0.2 release.

  • STEP 1

Please Support My work by Making a Donation.

  • STEP 2

Install Portainer using my step by step guide. If you already have Portainer installed on your Synology NAS, skip this STEP. Attention: Make sure you have installed the latest Portainer version.

  • STEP 3

Make sure you have a synology.me Wildcard Certificate. Follow my guide to get a Wildcard Certificate. If you already have a synology.me Wildcard certificate, skip this STEP.

  • STEP 4

Go to Control Panel / Login Portal / Advanced Tab / click Reverse Proxy. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 1 new 2023

  • STEP 5

Now click the “Create” button. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 2 new 2023

  • STEP 6

After you click the Create button, the window below will open. Follow the instructions in the image below.

On the General area, set the Reverse Proxy Name description: type in Nextcloud. After that, add the following instructions:

Source:
Protocol: HTTPS
Hostname: nextcloud.yourname.synology.me
Port: 443

Check Enable HSTS

Destination:
Protocol: HTTP
Hostname: localhost
Port: 8082

Nextcloud Synology NAS Docker Setup 3 new 2023

  • STEP 7

On the Reverse Proxy Rules click the Custom Header tab. Click Create and then, from the drop-down menu, click WebSocket. After you click on WebSocket, two Header Names and two Values will be automatically added. Click Save. Follow the instructions in the image below.

Synology Proxy WebSocket

  • STEP 8

Go to Control Panel / Network / Connectivity tab/ Check Enable HTTP/2 then click Apply. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 4 new 2023

  • STEP 9

Go to Control Panel / Security / Advanced tab/ Check Enable HTTP Compression then click Apply. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 5 new 2023

  • STEP 10

Go to File Station and open the docker folder. Inside the docker folder, create one new folder and name it nextcloud. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.

Nextcloud Synology NAS Docker Setup 6 new 2023

  • STEP 11

Now create seven new folders inside the nextcloud folder that you created at STEP 10 and name them config, custom_apps, data, db, html, redis, themes. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.

Nextcloud Synology NAS Docker Setup 7 new 2023

  • STEP 12

Download (click on the blue link below) and upload the my.cnf file below in the db folder that you have previously created at STEP 11. Follow the instructions in the image below. 🔒Note: Support my work to unlock the password. You can use this password to download any file on mariushosting forever!

👉🏻Download my.cnf

Nextcloud Synology NAS database configuration

  • STEP 13

Right click on the nextcloud folder that you have previously created at STEP 10 then click Properties. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 8 new 2023

  • STEP 14

Go to the Permission tab then click Advanced options. From the drop-down menu choose “Make inherited permissions explicit“. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 9 new 2023

  • STEP 15

Select Everyone then click the Edit tab. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 10 new 2023

  • STEP 16

Check all Read and Write Permissions. Click Done. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 11 new 2023

  • STEP 17

After you click Done on STEP 16, check “Apply to this folder, sub-folders and files“. Click Save. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 12 new 2023

  • STEP 18

Log into Portainer using your username and password. On the Portainer left sidebar click on Stacks then + Add stack. Follow the instructions in the image below.

1 Synology Portainer Add Stack

  • STEP 19

In the Name field type in nextcloud. Follow the instructions in the image below.

Note: In the Portainer Stacks Web editor Copy Paste the code below.

version: '3.9'
services:
  mariadb:
    container_name: Nextcloud-DB
    image: mariadb:11.3-jammy
    security_opt:
      - no-new-privileges:true
    user: 1026:100
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb-read-only-compressed=OFF
    volumes:
      - /volume1/docker/nextcloud/db:/var/lib/mysql:rw
      - /volume1/docker/nextcloud/db:/etc/mysql/conf.d:rw
    environment:
      - MYSQL_ROOT_PASSWORD=rootpass
      - MYSQL_PASSWORD=mariushosting
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - TZ=Europe/Bucharest
    restart: on-failure:5
      
  redis:
    image: redis
    container_name: Nextcloud-REDIS
    hostname: nextcloudredis
    user: 1026:100
    healthcheck:
     test: ["CMD-SHELL", "redis-cli ping || exit 1"]
    volumes:
      - /volume1/docker/nextcloud/redis:/data:rw
    environment:
      TZ: Europe/Bucharest
    restart: on-failure:5
      
  nextcloud:
    container_name: Nextcloud
    ports:
      - 8082:80
    depends_on:
      mariadb:
       condition: service_started
      redis:
       condition: service_healthy
    environment:
      - REDIS_HOST=nextcloudredis
      - NEXTCLOUD_TRUSTED_DOMAINS=nextcloud.yourname.synology.me 192.168.1.18
      - TRUSTED_PROXIES=nextcloud.yourname.synology.me 192.168.1.18
      - OVERWRITEHOST=nextcloud.yourname.synology.me
      - OVERWRITEPROTOCOL=https
      - MYSQL_PASSWORD=mariushosting
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=mariadb
    healthcheck:
     test: curl -f http://localhost:80/ || exit 1
    volumes:
      - /volume1/docker/nextcloud/html:/var/www/html:rw
      - /volume1/docker/nextcloud/custom_apps:/var/www/html/custom_apps:rw
      - /volume1/docker/nextcloud/config:/var/www/html/config:rw
      - /volume1/docker/nextcloud/data:/var/www/html/data:rw
      - /volume1/docker/nextcloud/themes:/var/www/html/themes:rw
    image: nextcloud
    restart: on-failure:5
    
  cron:
   image: nextcloud:apache
   container_name: Nextcloud-CRON
   restart: always
   volumes:
     - /volume1/docker/nextcloud/config:/var/www/html/config:rw
     - /volume1/docker/nextcloud/html:/var/www/html:rw
     - /volume1/docker/nextcloud/custom_apps:/var/www/html/custom_apps:rw
     - /volume1/docker/nextcloud/data:/var/www/html/data:rw
   entrypoint: /cron.sh
   depends_on:
    mariadb:
       condition: service_started
    redis:
       condition: service_started

Note: Before you paste the code above in the Web editor area below, change the value numbers for user with your own UID and GID values. (Follow my step by step guide on how to do this.) 1026 is my personal UID value and 100 is my personal GID value. You have to type in your own values.
Note: Before you paste the code above in the Web editor area below, change the value for MYSQL_PASSWORD and MYSQL_PASSWORD. Type in your own password for both values; they have to be identical. mariushosting is an example for a password.
Note: After you paste the code in the Web editor, change the value for TZ (Select your current Time Zone from this list).
Note: Before you paste the code above in the Web editor area below, change the value for NEXTCLOUD_TRUSTED_DOMAINS with your own synology.me DDNS without https:// at the beginning that you have previously created at STEP 6. Type in your own local NAS IP. The DDNS and your own local NAS IP are separated by space. 192.168.1.18 is my NAS local IP. You should add your own NAS local IP.
Note: Before you paste the code above in the Web editor area below, change the value for TRUSTED_PROXIES with your own synology.me DDNS without https:// at the beginning that you have previously created at STEP 6. Type in your own local NAS IP. The DDNS and your own local NAS IP are separated by space. 192.168.1.18 is my NAS local IP. You should add your own NAS local IP.
Note: Before you paste the code above in the Web editor area below, change the value for OVERWRITEHOST with your own synology.me DDNS without https:// at the beginning that you have previously created at STEP 6.

Nextcloud-Synology-NAS-Set-up-8-new-2027

  • STEP 20

Scroll down on the page until you see a button named Deploy the stack. Click on it. Follow the instructions in the image below. The installation process can take up to a few minutes. It will depend on your Internet speed connection.

Nextcloud Synology NAS Set up 9 new 2024

  • STEP 21

If everything goes right, you will see this message at the top right of your screen: “Success Stack successfully deployed“.

Nextcloud Synology NAS Docker Setup 15 new 2025

  • STEP 22

Go back to STEP 1 or you will deal with karma 🙂.

  • STEP 23

Now open your browser and type in your HTTPS/SSL certificate like this https://nextcloud.yourname.synology.me In my case it’s https://nextcloud.mariushosting.synology.me If everything goes right, you will see the Nextcloud main page. Type in your own Username and Password then click Install. You should wait 3-4 minutes because the installation process will take some time. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 16 new 2023

  • STEP 24

Install the recommended apps. Click Install recommended apps. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 17 new 2024

  • STEP 25

Your Nextcloud Installation will look like this.

Nextcloud Synology NAS Docker Setup 18 new 2023

  • STEP 26

Activate Cronjobs. At the top right of the page click on your profile icon then Administration settings. On the left sidebar click Basic settings then check Cron. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup Activate CronJob 2025

  • STEP 27

At the top right of the page click View profile then Edit Profile. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 19 new 2023

  • STEP 28

Type in your own Gmail Address then click Basic settings. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 20 new 2023

  • STEP 29

Follow my step by step guide on how to activate SMTP for your Gmail account. This step is mandatory. Note: If you don’t want to use the easiest way for SMTP with Google and you already have SMTP details from your own Mail Server, you can just skip this STEP and use your personalized email SMTP details instead.

  • STEP 30

On the Email server area type in your own Email details then click Save. Click Send email. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 21 new 2023

  • STEP 31

Check your email. Follow the instructions in the image below.

Nextcloud Synology NAS Docker Setup 22 new 2023

  • STEP 32

You can also Add Gmail Details to Nextcloud Mail.

  • STEP 33

Let’s fix carddav and caldav! In File Station go to the nextcloud folder then html. Download the .htaccess file to your computer then open it with Notepad. From the .htaccess file remove these two lines below:

RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]

Nextcloud Synology NAS Docker Setup 23 new 2023 1

And replace with these lines below.

RewriteRule ^\.well-known/carddav https://nextcloud.yourname.synology.me/remote.php/dav/ [R=301,L]
RewriteRule ^\.well-known/caldav https://nextcloud.yourname.synology.me/remote.php/dav/ [R=301,L]

See the example in the image below.

Nextcloud Synology NAS Docker Setup 24 new 2023 2

Save the .htaccess file then upload it to the html folder. Warning: Remember to delete the old .htaccess file in the html folder and then upload your new .htaccess file. Also, it’s mandatory to add the (dot) . at the beginning of the .htaccess file to make it work. If you forget the dot at the beginning of the file, this will not work.

Nextcloud Synology NAS Docker Setup 25 new 2023

Enjoy your Nextcloud via Docker!

🔥Troubleshooting

Note: What if I get error 0770? Your data directory is readable by other users.
Please change the permissions to 0770 so that the directory cannot be listed by other users.

0770 nextcloud

If you get this error Right click on the nextcloud folder in File Station then click Properties. Click on the Permission tab then go to the Advanced options. Select Make inherited permissions explicit. Now Select User “Everyone” then Delete it using Delete tab. Check “Apply to this folder, sub-folders and files”. Click Save.

Note: Find out how to update Nextcloud container with the latest image.
Note: Can I run Docker on my Synology NAS? See the supported models.
Note: You can also install Nextcloud using the standard installation method for nextcloud.
Note: If you encounter mem_swappiness issue contact me for instructions on how to solve it.
Note: Nextcloud together with the OnlyOffice document server.
Note: How to Free Disk Space on Your NAS if You Run Docker.
Note: How to Schedule Start & Stop For Docker Containers.
Note: How to Activate Email Notifications.
Note: How to Add Access Control Profile on Your NAS.
Note: How to Change Docker Containers Restart Policy.
Note: How to Use Docker Containers With VPN.
Note: Convert Docker Run Into Docker Compose.
Note: How to Clean Docker.
Note: How to Clean Docker Automatically.
Note: Best Practices When Using Docker and DDNS.
Note: Some Docker Containers Need WebSocket.
Note: Find out the Best NAS Models For Docker.
Note: Activate Gmail SMTP For Docker Containers.

This post was updated on Friday / February 23rd, 2024 at 2:34 PM