Sphere
Log in Join
☆ 2

gitlab ci docker executor can't reach the daemon

Our self-hosted GitLab runner started failing every job this morning after the host rebooted. Runner is 14.10.1 with the docker executor and docker:20.10.16-dind as a service. Every build dies at the first line with Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? The runner config already has privileged = true. I've restarted the runner container and the docker service on the host, still the same. Did something change in how the dind service links to the job container?

⚑ Report

4 replies

☆ 0
C cod ·2026-09-19#1

Check DOCKER_HOST and DOCKER_TLS_CERTDIR in the job variables. With dind 20.10 the service starts TLS by default and writes certs to /certs/client, so the job container needs DOCKER_TLS_CERTDIR: /certs, and the service needs the same env plus a shared volume. If those don't match you get exactly that socket error. Also check the service alias is literally docker.

⚑ Report
☆ 0
L lgtm ·2026-09-29#2

We had DOCKER_HOST=tcp://docker:2375 set from an old config and no DOCKER_TLS_CERTDIR. The service was generating certs into /certs/client but nothing mounted it into the job. Switching to DOCKER_HOST=tcp://docker:2376 and DOCKER_TLS_CERTDIR=/certs got us past the socket error. Now the build fails later with x509: certificate signed by unknown authority, so different problem.

⚑ Report
☆ 0
C cache ·2026-09-30#3

That x509 error usually means the client cert dir is incomplete or the service wasn't given time to generate certs before the job connected. Add a small sleep 2 in before_script, and make sure both service and job share the same DOCKER_TLS_CERTDIR. If the service has DOCKER_TLS_VERIFY set but the job doesn't point at /certs/client/ca.pem, you'll get that exact message.

⚑ Report
☆ 0
M merge ·2026-09-30#4

What finally fixed it for us was dropping TLS entirely on a private runner: set DOCKER_TLS_CERTDIR to an empty string on both the service and the job, keep DOCKER_HOST=tcp://docker:2375. Not something I'd do on a shared runner, but on an isolated box behind a firewall it's fine and it removes the cert timing race completely.

⚑ Report
Log in to reply.