CI pipeline fails: Docker-in-Docker (docker:dind) fails to start properly
https://gitlab.com/postgres-ai/database-lab/-/jobs/10494520192
CI pipeline jobs intermittently fail when using Docker-in-Docker (docker:dind) with the following error:
dial tcp: lookup docker on : no such host
failed to load listeners: can’t create unix socket /var/run/docker.sock: device or resource busy
The issue appears during the docker build step, after attempting to authenticate with the Docker registry.
Root Cause
-
docker:dindis started without explicitly enabling TCP mode. -
.gitlab-ci.ymlis configured with:DOCKER_HOST: tcp://docker:2375which requires dind to expose TCP.
-
Meanwhile, config.toml for the GitLab Runner includes this volume:
"/var/run/docker.sock:/var/run/docker.sock"which conflicts with Docker-in-Docker by trying to mount host’s socket inside the job container.
-
As a result, docker:dind fails to start its own dockerd correctly.