Skip to content
Latchkey

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

  1. Run docker info as the first command to confirm the client reaches dind.
  2. Match the docker client and docker:dind service versions.
  3. Ensure DOCKER_HOST matches the dind service alias and port.

How to prevent it

  • Standardize a dind template (service, DOCKER_HOST, TLS) and extends it.
  • Pin matching docker and docker:dind versions.
  • Probe with docker info before the build to fail fast.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →