In my Docker Traefik guide and Docker Nginx Proxy Manager guide, I hinted at being able to use any Docker Compose snippets from my GitHub Repo to easily build a Synology NAS docker media server.
I have Docker stacks running on 3 different environments: 1) Ubuntu VM on Proxmox cloud dedicated server, 2) Ubuntu Server on Digital Ocean VPS, and 3) Synology DS918+ with DSM 7.1.X. Compose snippets from any of those stacks can be plugged into others.
In this post, I will show you how to build a media server using Docker on Synology and with Nginx Proxy Manager for a simple reverse proxy or Traefik for a much more powerful stack. Or, you can even opt to not have a reverse proxy if you do not plan to expose your services outside your home network.
Note that this guide focuses on setting up/preparing your NAS to be able to build a Docker Traefik stack or Docker Nginx Proxy Manager stack on Synology DSM using Docker Compose examples from my GitHub Repo. We will prepare the Synology so you can follow my other guides to get your stack setup. Don't worry I will link to all relevant sections as needed.
Table of Contents
- Synology Docker Background Info
- Docker and Docker-Compose on Synology NAS
- Building the Synology Docker Compose Stack
- Known Issues
- Troubleshooting
- Membership Required
- Synology Docker Compose Stack - Final Thoughts
Synology Docker Background Info
In 2019, I moved from an HTPC NAS Combo server to a separate Intel NUC Home Server and Synology NAS. [Read: Moving from a Home Server to NAS (Synology) – The why, learnings, and tips]
One of the main reasons for my move was that I wanted a set it and forget it box for Plex, file storage, and database services. With hardware transcoding support, Synology DS918+ was one of the best media server for Plex at the time.
Another enticing factor about Synology was its support for Docker. In this Synology DSM docker guide, I will share how to use Docker Compose to easily setup a media server on Synology DS918+. This guide should work on any Synology model that supports Docker.
Is a Synology powerful enough for Docker Media Server?
As I have said in my other posts, I run over 60 docker containers on my primary Ubuntu-based home server, which is the heart of my smart home setup.
I run a few services (~20 or so) on my Synology with 8 GB of RAM, without any issues. However, this entirely depends on the application itself. If you run a lot of disk-intensive applications (eg. Arr apps, downloaders, UniFi controller, etc.), then expect slowness, which may eventually also impact the read speeds for any media servers you may be running. [Read: 15 Best Plex Alternatives [2022] – FREE and BETTER Options]
Here is my idle usage:
Plex was not playing anything and Tdarr was not converting videos. If these two were running, the usage would have been significantly higher.
DS918+ model support hardware transcoding. So both Plex and Tdarr have the GPU passed on to them for hardware transcoding, which should help a bit. But RAM will be one of the biggest limitations in a Docker Synology server setup (more on this below).
My Synology NAS
My DS918+ (and the newer DS920+) model came with 4 GB. Officially, these model supports up to 8 GB of RAM (2x4 GB). But unofficially, you can go to 16 GB of RAM. This is the case for several of the newer and mid to high-tier Synology models. So be sure to research your model.
Synology Models | Memory Type | Official (Synology Memory) | Third-Party Memory |
---|---|---|---|
DS920+, DS720+, DS420+, DS220+ | DDR4-2666 non-ECC unbuffered SO-DIMM 260 pin 1.2V | D4NESO-2666 4GB | Crucial 4GB Crucial 8GB Crucial 16GB |
DS1019+, DS918+, DS218+, DS418play | DDR3L-1866 non-ECC unbuffered SO-DIMM 204 pin 1.35V | D3NS-1866L 4GB | Crucial 4GB Crucial 8 GB Crucial 16GB |
Other Synology models | Crucial brand memories with the same spec as the official RAMs should work. | ||
Synology j models | RAM memory cannot be upgraded |
Here are the upgrades I did for my Synology NAS:
- RAM - Added additional 4 GB. Not all makes and models are compatible. Synology branded RAMs are expensive. But Crucial 4GB 204-pin SODIMM DDR3 PC3-14900 worked.
- 2 x HP EX920 M.2 256GB PCIe Nvme SSD for Caching, which is averaging nearly 100% fill and 98% hit rate per month.
I recommend adding the M2 cache, which will prolong the life of your NAS drives. It will also improve the performance of your Plex UI (loading thumbnails, etc.).
My Synology NAS is being backed up to Google Drive using the built-in Cloud Sync app. [Read: Fix for Synology Cloud Sync stops syncing with “up-to-date” message]
Why use Docker Compose on Synology instead of Synology DSM Docker GUI?
Synology DSM has a great GUI for docker. It allows you to browse images, setup containers, and manage them from the web interface. So why use Docker Compose instead?
Well, if Docker makes installing apps easier, then Docker Compose takes it to another level.
It makes your stack portable and moving from one machine to another a breeze. For example, in my recent moves, all I had to do was setup the OS, install docker and docker-compose, and start the stack. I was back in business in literally 30 min.
Similarly, when I moved some of my apps between servers, all I had to do was copy over the docker-compose to Synology and start it.
Essentially, Docker Compose eliminated several clicks and steps that would have been needed to setup the same stack using the Synology DSM Docker GUI.
Be the 1 in 200,000. Help us sustain what we do.Join Us (starting from just $1.67/month)
It is also possible to use Portainer GUI to build your stack. I prefer the native docker-compose as a uniform way to do it across platforms. Plus, you have one place to configure all your services, including Portainer.
Docker and Docker-Compose on Synology NAS
With all the background information taken care of. Let us now move on to setting up a docker media server on Synology using Docker-Compose. Once again, I remind you that this Synology Docker-Compose tutorial is more about preparing your Synology so you can follow my Docker Nginx Reverse Proxy or Docker Traefik tutorial.
Alternatively, you can choose to skip setting up a reverse proxy if do not plan to expose your services to the internet (access within from home network). Whichever path you choose, there is some more work to be done before starting our Synology NAS Docker stack.
1. Install Docker on Synology
First, is the easy step. Install Docker on Synology Disk Station Manager. Open Synology DSM package center, search for Docker and install it as shown in the screenshot below.
Unlike on Linux, the Synology Docker installation installs both Docker Engine and Docker Compose.
2. SSH into Synology DSM
Synology does not provide a terminal interface via the WebUI. So you will need to SSH into Synology from another machine.
To enable SSH on Synology, open control panel and go to Terminal & SNMP as shown below. Check Enable SSH service. The default port is 22. You may change the port to something else for additional security.
Here is one more benefit of Docker Compose on Synology, you can follow my Guacamole Docker guide and setup a browser-based remote desktop client on Synology. Once done, your Synology terminal is available from anywhere. All you need is a browser.
After enabling SSH, connect to your Synology DSM's SSH terminal from a remote machine. On Windows, you could one of the recommended SSH clients or even Windows PowerShell.
3. Install Docker Compose on Synology
Wait, I thought you said Synology's Docker package installs both Docker and Docker Compose.
Yes, I did say that. But Synology's docker packages usually tend to be quite old. So let's manually install/upgrade Docker Compose on Synology DSM.
To install Docker Compose on Synology NAS, SSH into the NAS and issue the following commands in sequence:
sudo su cd /var/packages/Docker/target/usr/bin/ mv docker-compose docker-compose_bak
The last command does a backup of the current docker-compose. Next, let's download the latest Docker Compose file:
curl -L https://github.com/docker/compose/releases/download/vX.XX.X/docker-compose-`uname -s`-`uname -m` -o docker-compose
Be sure to replace the vX.XX.X with the latest docker compose release number.
Then, give execute privileges to docker-compose:
chmod +x docker-compose
Now if you check the Synology Docker-compose version, you should see the latest version active.
Ok, we are inching closer to setting up a Synology Traefik Docker stack using Docker Compose.
4. Enable Home Folder for User
This is an optional convenience step and is not necessary. I like to use bash_aliases to simplify docker-compose commands.
For that, you will have to enable Home Folder for the user on Synology NAS.
To enable user home folder on Synology DSM, open control panel and go to User->Advanced. Scroll down and enable user home service as shown below.
Note that the location of the home folder may be different based on how your Synology volumes are set up. I only have one volume.
When the Docker package is installed on Synology DSM, a new shared folder for docker is created: /volume1/Docker (the volume number could be different in your case). Let's call this the "Docker Root" folder.
Let's give the Synology user read-write access to the Docker shared folder. Open control panel, go to User, highlight the main user (the user you normally login as), and click the Edit button.
Then go to the permissions tab and enable Read/Write for the user on the Docker shared folder, as shown below.
6. Change User and Docker Socket Permissions
Running and managing docker containers requires sudo privileges. So this means you will have to type sudo for every docker command or switch to the root user account. Otherwise, you will see the following error:
You can get around this by adding the current user to the docker group using the following command:
sudo synogroup --add docker username
Replace username with your username.
7. Ensure Ports 80 and 443 are Free
A reverse proxy (e.g. Nginx Proxy Manager or Traefik) requires ports 80 and 443 to be free. Some Synology apps such as (WebStation, PhotoStation, Nginx Reverse Proxy, etc.) use these ports.
Check out of definite guide to freeing up ports 80 and 443 on Synology NAS.
Once Nginx Proxy Manager or Traefik is up you can always put the Synology apps (e.g. WebStation) behind a reverse proxy to make it accessible externally using a fully qualified domain name.
Building the Synology Docker Compose Stack
That is it for prep work. From here you have a few different ways to go:
- Build a docker stack without reverse proxy - Your services will not be exposed to the internet. This means to access your apps you will have to use the internal network IP address and service's port (e.g. http://192.168.1.100:7878 for radarr). You will not have a nice looking fully qualified domain name (although there is a workaround for this with PiHole or AdGuard Home's Local DNS feature). [Read: Pi-Hole vs AdGuard Home for Ad Blocking – 12 Key Differences]
- Build a docker stack with reverse proxy - Your services will be exposed to the internet using a nice looking fully qualified domain name (e.g. https://radarr.domain.com). We have previously covered two different reverse proxies:
- Nginx Proxy Manager
- Traefik
You will have to decide which way you want to from here and follow the steps below accordingly.
Requirements for Synology Docker Compose Stack
Here are a few more key requirements to meet before building the docker-compose stack on Synology Network Attached Storage.
1. Create Environmental Variables
Next, regardless of whether you will use a reverse proxy or not, you will need to Setup the Docker environment exactly as described in the Docker guide. On Synology, my docker root folder is /volume1/docker.
2. Familiarize yourself with my GitHub Repo
You can use any of the YML files for reference. My main one is docker-compose-t2.yml but the one specific to Synology is docker-dompose-t2-synology.yml.
3. Docker and Docker Compose Usage
This is a good point to stop a bit and familiarize yourself with Docker and Docker Compose commands. Since this has been covered in detail already, I will refer you to my other guide: Docker and Docker Compose Usage.
4. Setup Bash Aliases on Synology
As I mentioned before, this step is mainly for convenience. Doing so makes it easy to start up and down the Synology Docker Compose stack (eg. dcup2 to start the docker stack). You can read more about in my docker traefik guide.
To setup bash aliases on Synology, create a bash_aliases text file in a known location. For simplicity, let's creates file called bash_aliases.txt inside the docker root folder (/volume1/Docker).
Then, add contents from bash aliases example file from my repo. Customize it to your liking but ensure that the path to the docker-compose files is correct.
Next, run the following two commands in sequence (not as root but as the user). The second command will create a symbolic link to the bash aliases text file and the last command will update the shell session with updated bash aliases.
cd /var/services/homes/username ln -s /volume1/docker/bash_aliases.txt .bashrc . ~/.bashrc
Again, username should be your username. Once done, you should see .bashrc symlinked to the bash_aliases.txt file, as shown below (using the command ls -al.
5. Domain and DNS - Only if Using Reverse Proxy
I will not go into the details of the requirements as they have been explained previously. But here are the relevant links if you plan on setting up a reverse proxy like NPM or Traefik, which are covered in Options 2 and 3 below:
Option 1: Synology Docker Stack without Reverse Proxy
If you do not plan to expose your services to the internet, then you do not need a reverse proxy. You can use port forwarding to access them from outside your home network without a reverse proxy, but do not do it - this is a security risk.
To continue building your Synology NAS Docker Compose stack, follow the steps below:
Starting building your docker-compose file
Follow the heading linked above to complete the steps below.
Define Docker Compose File Basics
You can call your docker-compose file whatever you want. I call mine docker-compose-t2-synology.yml since I use Traefik on my Synology. Make sure all our commands and bash_aliases use the right file name.
Define Default Network
Since you won't be using a reverse proxy, you can just define a default docker network:
########################### NETWORKS networks: default: driver: bridge
Or, optionally define a subnet:
########################### NETWORKS # You may customize the network subnet (192.168.88.0/24) below as you please. # Docker Compose version 3.5 or higher required to define networks this way. networks: default: driver: bridge name: default ipam: config: - subnet: 192.168.88.0/24
You do not need to define the network npm_proxy or t2_proxy as in some of my other guides.
Define Extension Fields
Define the extension fields as in the above link but leave out the networks: part or use default for network name as shown below:
networks: - default
Be sure to read and understand how the extension fields work.
Start Adding Docker Containers
Since you will not be using a reverse proxy, skip the Nginx Proxy Manager part. Start from Portainer.
Copy-paste the Portainer docker snippet. Start it and test it as described in my Docker guide.
To continue building your Synology NAS Docker stack, you may copy-paste any service from any of my docker-compose files in the GitHub repo. You will just have to expose the ports to your Docker host so you can access the service using DOCKER-HOST-IP:PORT. In the case of portainer, this is defined in the following lines of the docker-compose snippet:
ports: # Comment out if using Nginx Proxy Manager to access portainer WebUI. - "9000:9000"
You also will have to ignore the whole docker labels section for each service as these are specific to Traefik (docker-compose-t2-XXXX files).
Option 2: Reverse Proxy with Nginx Proxy Manager
If you want to setup Nginx Proxy Manager as your reverse proxy for the Docker stack on Synology, then you are in luck.
All you need to do is follow the steps outlined in my Docker Media server guide pretty much word-to-word.
Just remember that the Docker Root Folder may be different here (/volume1/docker).
Start from Building Docker Media Server and follow the guide to the end. That is it.
Option 3: Reverse Proxy with Traefik
Synology Traefik Docker setup also follows pretty much my Traefik guide.
Definitely read the introduction part and basic information, including Traefik 2 Setup before proceeding.
Continue to follow the Traefik 2 Configuration section till the end of the guide. Along the way, pick and choose the services you want.
For simplicity and compatibility with the existing files in my GitHub repo, I am calling my Synology Docker-Compose file docker-compose-t2-synology.yml. You can call it docker-compose.yml if you prefer. Just make sure your bash aliases are edited accordingly.
Be the 1 in 200,000. Help us sustain what we do.Join Us (starting from just $1.67/month)
Adding Other Apps to Synology Traefik Docker Stack
My Synology docker stack is constantly changing and evolving. I split my entire stack between Synology and Intel NUC. Refer to my GitHub Repo to find out what app runs where.
Having said that, you can copy-paste the snippets from any of the docker-compose files in my repo to your docker-compose file on Synology and you should be able to add the app to your stack. You can even run your own Docker WordPress Site on Synology.
Additional Reading
As I said before, this guide is to be followed in conjunction with my previous guides. I do not go into a lot of detail in this guide. If you have been taking shortcuts so far (not reading my previous guide), then here are some key sections that you might find useful:
- Cloudflare Settings for Traefik Docker: DDNS, CNAMEs, & Tweaks
- Adding non-docker or external apps behind Traefik - A good example is putting Synology DSM WebUI behind Traefik
- In this guide, I did not cover some of the security aspects. I strongly recommend reading best Docker security practices to harden your setup.
Known Issues
This Synology Docker Compose guide works. But there are a couple of known issues. One is already mentioned above: Synology's docker implementation does not auto-create missing folders on the host machine.
Logging Issue
The other one is: if you use docker-compose to define your docker-traefik stack on Synology, your DSM's Docker GUI app's functionality will be reduced. You will have less control over the containers and docker logs will not appear in the GUI. You can still start and stop your containers from the GUI.
My recommendation is if you use docker-compose on Synology, move to it 100%. This avoids any unexpected behaviors.
Troubleshooting
Everything mentioned under troubleshooting sections for Docker and Traefik guides apply here as well.
Most common errors include: typos, YAML indentation errors, ports 80 and 443 already in use, ports 80 and 443 not forwarded on the router, traefik middlewares not defined, CNAMEs not defined properly on DNS records, acme.json file has wrong permissions, etc.
In addition, a common error while deploying Docker compose stacks on Synology is the Bind mount failed: volume does not exist error.
I have not tested it but another workaround may be creating named volumes in docker-compose.
Synology Docker Compose Stack - Final Thoughts
When I started doing my research on setting up a docker media server on Synology, there wasn't enough coherent information out there. I spent several hours putting pieces together and figuring things out by trial and error.
At this point, my docker traefik Synology setup is working flawlessly. Plus, it is nearly 100% compatible with the compose files on my GitHub repo. The only issue seems to be having to manually create the folders that are mapped as persistent volumes in the docker-compose files. This is a minor one-time inconvenience.
I hope this Docker Compose Synology guide helps you get started on your docker journey on Synology NAS.