Running GitLab Runner on Docker on Synology

Hello,

I am trying to set up GitLab Runner in a “restricted” Docker environment - a Synology DiskStation running DSM 6.2.4. The GitLab Runner was pushed on January 19th 2022 to Docker Hub.

The issue arises from the fact that I cannot add this part to the container configuration:
-v /var/run/docker.sock:/var/run/docker.sock
The Synology Docker UI won’t let me pick anything under /var/ for the mapping, and if I try to overwrite the configuration JSON file manually, then Synology resets it and removes the ‘non-compliant’ part.

As a result, I keep getting the following when I try to run the GitLab Runner container:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.

Any ideas or workarounds? I’ve tested the GoCD option, as well as JetBrains’ TeamCity option, and would like to stick to GitLab CI/CD if possible.

Many thanks in advance!

Not sure what Synology device you are using. I have a DS218+ with additional ram installed, so I can run virtual machines on it. So, depending on your Synology hardware, you could create a virtual machine, and inside the virtual machine run docker and configure your runner inside this virtual machine.

Far better than attempting to mess around with the Synology-based docker version which as you found out, is rather restrictive.

1 Like

Thanks for the reply! RAM is not the issue (I have 16 GB installed) but the CPU is (Synology likes to use fairly low-end CPUs and my C2538 is a bit overwhelmed by everything I throw at it). So I prefer Docker instead of VMs.

Nevertheless, I’d appreciate a ‘proper’ solution for this, as this is one of the few Docker images which has been giving me headaches for some time now (managed to get a dozen others working, with more or less tinkering around ^^).

From a link I found: Setup GitLab Runner for Docker containers on Synology NAS – mixable Blog

in particular the section on Gitlab runner:

docker run -d \
--name gitlab_runner_docker \
--restart always \<br>--network host \
-v /run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest

the difference being /run/docker.sock than what you wrote before. So:

-v /run/docker.sock:/var/run/docker.sock

Sadly, I cannot add anything from the root of the Synology OS (neither /var/, /opt/, /run/ or anything else). The Synology Docker package UI restricts me to only choosing folders under /volume1/.

So I tried adding this manually under the “Mountpoints” section in the container’s config.v2.json file:

"/var/run/docker.sock": {
        "Source": "/var/run/docker.sock",
        "Destination": "/var/run/docker.sock",
        "RW": true,
        "Name": "",
        "Driver": "",
        "Type": "bind",
        "Relabel": "rw",
        "Propagation": "rprivate",
        "Spec": {
          "Type": "bind",
          "Source": "/var/run/docker.sock",
          "Target": "/var/run/docker.sock"
        },
        "SkipMountpointCreation": false
      },

But it gets removed as soon as I stop and re-start the container.

The way I understand it from the link that I posted, that you need to log in via SSH to the Synology device and run the docker run command from the console and not from the GUI Docker interface. It wasn’t clear if you only attempted this in the GUI or via Admin and SSH access - and still have problems from console/ssh as well or not.

As admin though, I do have access to files under /run - so I think if you ran the docker run command from the console/SSH then it should work for you, as was written in the howto link.

admin@nas:/run$ cat /run/usb-copyd.pid 
14355

I don’t use docker, and so won’t install to test it, as I don’t want all the rubbish left behind on my NAS device. It seems using the Docker GUI will limit what you can do.

1 Like

Thanks @iwalker for your efforts !

I’m still waiting for someone who uses GitLab Runner from Docker Containers (and preferably on a Synology) to share their experience.

Also, perhaps GitLab Support can point me towards an alternative to binding

/var/run/docker.sock

@icarus86 my pleasure. Docker running on Linux isn’t a problem since I already have a Gitlab runner running in a VM with docker. This problem is purely unique to Synology unfortunately.

Hopefully there will be someone else who does use Docker on Synology might be able to help. Good luck!

Hey @icarus86 ,

The steps listed in the blog post that @iwalker mentioned earlier worked great.

You do have to SSH into your Synology for at least the very first step as the post mentions. You also need to run all the commands in the Synology as ‘root’ so, prefix the commands listed with sudo where necessary. It’ll ask you for your password. I just followed the post step-by-step and it got me to where the runner is now showing up in GitLab:

That’s as far as I’ve gotten. Now to figure out how to get the actual pipeline set up for the runner to act on. :grinning:

1 Like

Many thanks @Leeman , somehow it “magically” worked after upgrading to 15.9 (and sorry for my very late reply).