Skip to content

Instantly share code, notes, and snippets.

@gamma
Last active January 12, 2024 03:19
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gamma/a9691115df566941b54ae5537d522cd4 to your computer and use it in GitHub Desktop.
Save gamma/a9691115df566941b54ae5537d522cd4 to your computer and use it in GitHub Desktop.
How to connect a docker container to the docker daemon on a Synology NAS

Note: This originates from: https://forum.synology.com/enu/viewtopic.php?f=258&t=107508&sid=78d911737c5ecea1f9087bdab13612bf&start=15#p478281

Here are steps that I have modified to work for me. This assumes you have a shared folder named "docker" in volume1.

We need to Symlink /var/run/docker.sock to /volume1/docker/docker.sock, because Synology Docker GUI will not be able to run it when it's pointed directly to /var/run/docker.sock. Also the symlink needs to persist after reboot. To make it do so, you will need to create an automated task in your Synology DSM via "Task Scheduler".

  • Go to "Control Panel" > "Task Scheduler".

  • Click "Create" > "Scheduled Task" > "User-defined Script".

  • On the "Create Task: Window, make sure "User:" is selected as "root" and rename the "Task:" to whatever you like.

  • Click "Schedule" tab. Under "Date - Run on the following days", select "Daily". Under "Time - Frequency", select "Every 1 hour(s)" (just to be on the safe side).

  • Click "Task Settings" tab. Under "Run command - User-defined script", paste the following line into the text box and press "OK".

    sudo ln -s /var/run/docker.sock /volume1/docker/docker.sock

The newly created task will be listed there. Click to highlight it and then click "Run" to run it once immediately. Next, we need to download/pull and install the docker container. We can do all this with a single "docker run" command via shell.

  • First, SSH into Synology.

  • Then, run the following docker run command as sudo:

    sudo docker run -d --name watchtower -v /volume1/docker/docker.sock:/var/run/docker.sock centurylink/watchtower --interval 82800 --cleanup

You will now be able to run Watchtower via the Synology Docker GUI. You may also set it to restart automatically within the container settings.

Note: You may be able to do step 2 without using the shell (i.e. SSH) by scheduling a task like in Step 1 and deleting it after running it once. Feel free to try out any changes you like.

@tomgrv
Copy link

tomgrv commented Jun 7, 2022

for those who have docker on another volume:

find /volume? -maxdepth 1 -name docker -exec ln -s /var/run/docker.sock {}/docker.sock \;

@jolarsso
Copy link

jolarsso commented Aug 20, 2022

Thanks for this. I have spent the better part of an afternoon trying to configure Homarr to connect to the docker daemon on DSM through the GUI. I guess from here and on all containers will be configured from Portainer using yaml and I will never have to touch the DSM GUI again :)

I also don't seem to be able to add the github container repo URL (ghcr.io) through the DSM GUI either. Had to Google another workaround for that.

@knilde
Copy link

knilde commented Apr 8, 2023

Nice explanation. Thanks man!

@adevcoder
Copy link

Thank you for this.

@Kaven-W
Copy link

Kaven-W commented Nov 22, 2023

Another way by export/import settings:

    "volume_bindings" : [
   	  {
         "host_absolute_path" : "/var/run/docker.sock",
         "mount_point" : "/var/run/docker.sock",
         "type" : "rw"
      }
   ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment