GitLab CI dind "Docker daemon not reachable" (DOCKER_HOST)
A docker command ran but there was no daemon to talk to. In GitLab CI you must attach a Docker-in-Docker service and point the client at it via DOCKER_HOST.
What this error means
A docker build/docker push step fails immediately with "Cannot connect to the Docker daemon ... Is the docker daemon running?" The rest of the job is fine - only Docker has nowhere to connect.
gitlab-ci
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Is the docker daemon running?Common causes
No docker:dind service attached
The Docker executor does not give jobs a daemon by default. Without a docker:dind service there is no daemon for the client to reach.
DOCKER_HOST / TLS not configured
With dind over TLS the client needs DOCKER_HOST, DOCKER_TLS_CERTDIR, and the cert path set. Missing or mismatched values leave the client pointed at a non-existent socket.
How to fix it
Attach docker:dind and set the host
.gitlab-ci.yml
build:
image: docker:27
services:
- docker:27-dind
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_CERT_PATH: "/certs/client"
DOCKER_TLS_VERIFY: "1"
script:
- docker build -t myimage .Verify the daemon is reachable
- Run
docker infoas the first command to confirm the client reaches dind. - Match the
dockerclient anddocker:dindservice versions. - Ensure
DOCKER_HOSTmatches the dind service alias and port.
How to prevent it
- Standardize a dind template (service,
DOCKER_HOST, TLS) andextendsit. - Pin matching
dockeranddocker:dindversions. - Probe with
docker infobefore the build to fail fast.
Related guides
GitLab CI "image pull access denied" From the RegistryFix GitLab CI "pull access denied" / "denied: requested access to the resource is denied" - the job image is…
GitLab "Job failed (system failure): prepare environment"Fix GitLab "ERROR: Job failed (system failure): prepare environment" - a runner-side failure setting up the j…
GitLab "Preparation failed: Docker executor" ErrorsFix GitLab CI "ERROR: Preparation failed" on the Docker executor - the runner could not create the container,…