Make Docker on Synology NAS visible to other hosts (with Portainer)

Portainer is a really nice tool used to manage Docker containers on a specific machine. If we install it on the Synology NAS, it will automatically detect all the available containers. But what if in our local network we had multiple machines with separate Docker installations, holding different containers?
Let's imagine that we have a Synology NAS, as well as a Raspberry Pi. We can set things up so that we can run Portainer on the Raspberry Pi, but allow it also see the containers running on the Synology NAS.

Installing Portainer

Installing portainerWe use docker-compose.yaml to spin a Portainer container on the Raspberry Pi

portainer:  
  container_name: portainer  
  image: portainer/portainer-ce:latest  
  environment:
    - TZ=${TZ}  
  command: -H unix:///var/run/docker.sock  
  ports:
    - 9999:9000
    - 8888:8000
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock    
    - ${DOCKER_PATH}/portainer/data:/data  
  restart: always

Once Portainer is up and running, it's time to work on the Synology NAS.

Allowing external connections

We need to enable external connection on the Synology NAS and, to do so, we must enable TCP port 2375. It's pretty easy.

  • As usual, we first SSH into our Synology NAS.
  • Here, we need to edit a file called dockerd.json. To do so, we simply run sudo nano /var/packages/Docker/etc/dockerd.json.
  • Once the file is open, we need to add "hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]
  • We save the changes to the file.
  • We must now restart Docker.

Connecting

Now we just need to tell Portainer to look for Docker on the Synology NAS.

  • We visit Portainer on the Raspberry Pi.
  • From the sidebar, we go on Administration > Environment-related > Environments.
  • We click on + Add environment.
  • We select _Docker Standaloneand click onStart Wizard`.
  • We select API, we use any name (ie Synology), and we add the Docker API URL as SYNOLOGY_IP:2375.
  • Finally, we press Connect.