DB-유

Installing Docker on Synology

· synology, docker

I stopped hunting for community SPKs the day I realised the Synology could just run the official image of whatever I wanted, in a container, away from DSM itself. The catch is that the Docker package only exists for x86 models, and the GUI hides a few things you should know before the first container.

First check your hardware. Plus-series models (DS216+, DS716+, DS916+, DS1517+, DS1817+, DS918+ and similar), the RS line and the XS line qualify. ARM units (DS216j, DS218j, DS416slim and so on) don't get the package. You want DSM 6.0 or 6.1, and 2 GB of RAM is realistic; 1 GB units run Docker but not comfortably. Turn on SSH too if you want the command line (Control Panel → Terminal & SNMP).

Install the package

Open Package Center, search for Docker and click Install. The package creates a shared folder named docker on your first volume, so the path is /volume1/docker. This folder is where I keep all container configuration and data; keep that habit and backups become trivial.

Once installed, open Docker from the main menu. The tabs are Overview, Registry, Image, Container, Network and Log.

Pull an image

In the Registry tab, search for an image, for example nginx, select it and click Download. It asks for a tag; pick a specific version such as 1.13 rather than latest, so an upgrade only happens when you decide. I got burned by latest exactly once. The download shows in the Image tab with its size once complete.

From SSH the same thing is:

sudo docker pull nginx:1.13
sudo docker images

Note that docker needs root; either prefix with sudo or use sudo -i first. Adding your user to a docker group does not work on DSM the way it does on Ubuntu.

Run a container with persistent storage

The classic mistake is putting data inside the container. When you later upgrade the image the container is recreated and the data is gone. Always mount a folder from /volume1/docker.

Create a folder for the application via File Station or SSH:

sudo mkdir -p /volume1/docker/nginx/html /volume1/docker/nginx/conf.d

In the GUI: Image tab → select nginx:1.13 → Launch. In the wizard give it a name, then click Advanced Settings:

  • Enable auto-restart: on, so it comes back after a DSM reboot.
  • Volume → Add Folder: docker/nginx/html mounted at /usr/share/nginx/html; docker/nginx/conf.d mounted at /etc/nginx/conf.d.
  • Port Settings: change the Local Port for container port 80 from Auto to a fixed value like 8080. Auto assigns a random port at every start, which is useless for anything you bookmark.
  • Environment: add variables if the image needs them.

The equivalent on the command line is:

sudo docker run -d --name nginx \
  --restart unless-stopped \
  -p 8080:80 \
  -v /volume1/docker/nginx/html:/usr/share/nginx/html \
  -v /volume1/docker/nginx/conf.d:/etc/nginx/conf.d \
  nginx:1.13

Containers started from the command line show up in the GUI's Container tab as well, though the GUI's Edit function is limited on them.

Where things live

  • Container data you mount: /volume1/docker/....
  • Docker's own storage (images, container layers): /volume1/@docker. Do not touch it directly. It is on the same volume as the docker shared folder.
  • Package binaries: /var/packages/Docker/target/usr/bin/docker.
  • Restarting the daemon: sudo synoservice --restart pkgctl-Docker, or stop and start the package in Package Center.

Did it work?

sudo docker ps
curl -I http://localhost:8080

docker ps should list the container as Up, and curl should return HTTP/1.1 200 OK from nginx (put an index.html in /volume1/docker/nginx/html first, or you will get a 403). From another machine, browse to http://<nas-ip>:8080.

Check the container log in the GUI (Container → Details → Log) or with sudo docker logs nginx.

When it goes wrong

  • Docker is missing from Package Center: the model is not x86 or is not on the supported list. There is no supported way to install it on ARM models.
  • "Bind for 0.0.0.0:80 failed: port is already allocated" or a GUI error about the port being in use: DSM's own nginx occupies 80 and 443, and 5000/5001 are DSM. Pick a different local port.
  • Container starts and stops immediately: check the log. Typically a required environment variable is missing or the mounted folder has permissions the process cannot write to. Fixing ownership from SSH with chown -R 1000:1000 /volume1/docker/app is often the answer, depending on the UID the image runs as.
  • File Station shows the docker folder but you cannot delete @docker: you are not meant to. It is hidden from File Station for a reason.

After that it's the same routine every time: pinned tag, folder under /volume1/docker, mount it, fixed port, auto-restart.