The docker:dind service dies in GitLab CI because docker.sock is already mounted
Your error
failed to load listeners: can't create unix socket /var/run/docker.sock: device or resource busy1 more line it can showFix it fast
Most common cause, 1 of 2A Docker executor runner mounts the host socket and the job adds docker:dind
Pick one method for this runner.
# /etc/gitlab-runner/config.toml (dind runner)
[runners.docker]
image = "docker:29.10.0-cli"
privileged = true
volumes = ["/certs/client", "/cache"]
# .gitlab-ci.yml
default:
image: docker:29.10.0-cli
services:
- docker:29.10.0-dind
before_script:
- docker info
variables:
DOCKER_TLS_CERTDIR: "/certs"Short answer
failed to load listeners: can't create unix socket /var/run/docker.sock: device or resource busy appears when a job starts the docker:dind service on a runner that already bind-mounts the host's /var/run/docker.sock. GitLab documents the two methods as incompatible. Remove the socket volume from that runner or drop the dind service. Applies to GitLab Runner 19.x with Docker 29.
Which cause do you have?
Open the runner's configuration and look for two things: which executor it uses, and whether docker.sock appears among its volumes or host_path mounts. The executor line decides which cause below applies.
sudo grep -n -E 'executor|docker.sock|host_path|mount_path' /etc/gitlab-runner/config.tomlThen find the line you see in this list and open its fix:
- 1A Docker executor runner mounts the host socket and the job adds docker:dind
executor = "docker" and a volumes list that includes /var/run/docker.sock:/var/run/docker.sock - 2A Kubernetes executor runner has a host_path mount at /var/run/docker.sock
The Helm values or config.toml hold a [[runners.kubernetes.volumes.host_path]] block with mount_path = '/var/run/docker.sock'
What does the error look like?
failed to load listeners: can't create unix socket /var/run/docker.sock: device or resource busydocker: Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?
Cause 1 of 2
A Docker executor runner mounts the host socket and the job adds docker:dind
You seeexecutor = "docker" and a volumes list that includes /var/run/docker.sock:/var/run/docker.sock
Check
The device or resource busy message on /var/run/docker.sock means the dind daemon wants to create its own socket at a path the runner has already filled with the host's socket. GitLab's Docker build guide says a runner that binds the socket cannot run the dind service, because volume bindings reach service containers too.
grep -n -B2 -A2 'dind' .gitlab-ci.ymlFix
Pick one method for this runner. For dind, remove the socket from volumes, set privileged = true, mount /certs/client and keep DOCKER_TLS_CERTDIR. For socket binding, delete the services entry and any DOCKER_HOST variable so the client uses the host daemon.
# /etc/gitlab-runner/config.toml (dind runner)
[runners.docker]
image = "docker:29.10.0-cli"
privileged = true
volumes = ["/certs/client", "/cache"]
# .gitlab-ci.yml
default:
image: docker:29.10.0-cli
services:
- docker:29.10.0-dind
before_script:
- docker info
variables:
DOCKER_TLS_CERTDIR: "/certs"Verify
The job log shows a Server section from the dind daemon when docker info runs, and the listener failure is gone from the service output.
docker infoConfirmed by docs.gitlab.com
Cause 2 of 2
A Kubernetes executor runner has a host_path mount at /var/run/docker.sock
You seeThe Helm values or config.toml hold a [[runners.kubernetes.volumes.host_path]] block with mount_path = '/var/run/docker.sock'
Check
On the Kubernetes executor, every volume given to the build container is also mounted into each service container. A host_path mount for docker.sock therefore lands inside the dind service as well, and the daemon there cannot claim that path.
grep -n -A4 'host_path' values.yamlFix
Remove the host_path socket block from runners that serve dind jobs. Give them an in-memory empty_dir for /certs/client, run privileged, and point the client at the service over TLS on port 2376.
# values.yaml -> runners.config
[[runners]]
[runners.kubernetes]
privileged = true
[[runners.kubernetes.volumes.empty_dir]]
name = "docker-certs"
mount_path = "/certs/client"
medium = "Memory"
# .gitlab-ci.yml variables for the job
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_TLS_VERIFY: 1
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"Verify
The dind service container reaches running state in the job pod, and docker info answers through tcp://docker:2376.
kubectl get pods --namespace gitlab-runner --watchConfirmed by docs.gitlab.com
How do I stop it coming back?
- Tag dind runners and socket-binding runners differently, and put the matching tag on every job, so a dind job never lands on a socket runner.
- When concurrent dind jobs need a Unix socket, share a temporary /runner/services/docker volume and set DOCKER_HOST to unix:///runner/services/docker/docker.sock instead of reusing /var/run.
- Pin the dind service and the cli image to the same Docker version in .gitlab-ci.yml.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Dispatch Pro, TaxiDex.