GitLab Runner Docker TCP Error

About a month or so ago, I tried to install the GitLab Runner for some personal project usage, and kept getting hit with similar errors to below:

cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial tcp ...:2375: connect: connection refused
cannot connect to the docker daemon at tcp://docker:2375. is the docker daemon running?
error during connect: Post ... dial tcp: lookup docker on ...:53: no such host

I ended up leaving the issue for another day, and today managed to work out the issue.

The issue I was encountering is that the GitLab runner expected there to be a TCP socket available for the Docker process, whereas it appears that my installation (maybe due to how Docker is packaged for Debian?) by default only provided the file-based socket.

For additional context, I am running this on Debian Stretch (Debian 9), with GitLab Runner v12.9.0, and Docker v17.12.0-ce.

Providing Privileges to Interact with Docker

If it doesn't already have access, the user that gitlab-runner is executing as needs to be in the Docker group. For instance, assuming that the user gitlab is used to execute the runner:

$ sudo gpasswd -a gitlab docker

You may need to restart the gitlab-runner service first.

Creating the TCP Socket

Following these steps on StackOverflow, I was able to create a TCP socket using systemd:

[Unit]
Description=Docker Socket for the API
PartOf=docker.service

[Socket]
ListenStream=2375

BindIPv6Only=both
Service=docker.service

[Install]
WantedBy=sockets.target

This then exposes the TCP socket that to connect to Docker, and builds start working as soon as the new socket is available!

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #gitlab #docker.

This post was filed under articles.

Related Posts

Other posts you may be interested in:

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.