Some models of Synology NAS allow you to run applications in Docker containers.

Install Docker on your NAS

Follow the instructions on www.smarthomebeginner.com, summarizing:

  • Log in to your Synology NAS web interface, and install the “Docker” package

  • Log in to your Synology NAS using SSH, become root (‘sudo -i’)and run:

      root@nas# cd /var/packages/Docker/target/usr/bin
      root@nas# mv docker-compose docker-compose.ORIG
      root@nas# curl -L https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-`uname -s`-`uname -m` -o docker-compose
      root@nas# chmod 755 docker-compose
      root@nas# docker-compose version
      Docker Compose version v2.18.1
    

To check for newer versions, browse to the docker-compose releases page. Then, substitute “v2.18.1” in the ‘curl’ command above with the appropriate version number.

Choose type of networking

Initially, I will not use a reverse proxy. Ports 80 and 443 might be in use by the Diskstation software. I’ve decided to use ports 8080 and 8443 when adding a reverse proxy instead of changing the Synology default configuration.

I will use ‘bridge’ networking which means that the Docker containers share the IP address of the Synology NAS. You must select different port numbers for each application.

Environment

Create an environment file for Docker, similar to this:

~~~
root@nas# cat /volume1/docker/.env 
PUID=1000
PGID=1000
TZ="Europe/Amsterdam"
DOCKERDIR="/volume1/docker"
~~~

Getting started with docker-compose

Create a docker-compose.yaml file similar to this (minimal example, just runs the Portainer service on port 9000/tcp):

root@nas# cat /volume1/docker/docker-compose.yaml
###### Meta
version: "3.9"


###### NETWORKS
networks:
  default:
    driver: bridge


###### EXTENSION FIELDS
# Helps eliminate repetition of sections
# More Info on how to use this: https://github.com/htpcBeginner/docker-traefik/pull/228

# Keys common to some of the core services that we always to automatically restart on failure
x-common-keys-core: &common-keys-core
  security_opt:
    - no-new-privileges:true
  restart: always


###### SERVICES
services:

  # Portainer - WebUI for Containers
  portainer:
    <<: *common-keys-core     # See EXTENSION FIELDS at the top
    container_name: portainer
    image: portainer/portainer-ce:latest
    command: -H unix:///var/run/docker.sock
    ports: # Comment out if using Nginx Proxy Manager to access portainer WebUI.
      - "9000:9000"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro # Use Docker Socket Proxy and comment this line out, for improved security.
      - $DOCKERDIR/appdata/portainer/data:/data # Change to local directory if you want to save/transfer config locally.
    environment:
      - TZ=$TZ

Test your setup:

~~~
root@nas# cd /volume1/docker
root@nas# source .env
root@nas# docker-compose -f docker-compose.yaml up
~~~

Updated: