Skip to content
Latchkey

Docker "Cannot connect to the Docker daemon" (dind) in CI

The client could not reach a daemon at all. In CI this usually means Docker-in-Docker has not finished starting, the dind service is missing, or DOCKER_HOST points nowhere.

What this error means

Any docker command fails with Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. It often clears once the dind service is fully up.

docker
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Common causes

dind service not started yet

The Docker-in-Docker sidecar is still booting when the first docker command runs, so the socket is not ready.

No daemon / wrong DOCKER_HOST

No dind service is configured, or DOCKER_HOST points at an address with no daemon listening.

Missing privileged mode

dind needs privileged mode (or the right setup) to run; without it the daemon never starts.

How to fix it

Wait for and target the daemon

  1. Point DOCKER_HOST at the dind service and wait until it responds.
Terminal
export DOCKER_HOST=tcp://docker:2375
until docker info >/dev/null 2>&1; do sleep 1; done

Configure the dind service correctly

  1. Add a privileged docker:dind service or enable the dind option in your CI.
  2. Ensure TLS/host settings match between client and dind.

How to prevent it

  • Add a readiness wait for the dind daemon before the first docker command. Latchkey managed runners provide a ready Docker daemon and auto-retry transient daemon-not-ready startup races, so jobs do not fail on a boot timing blip.

Frequently asked questions

What causes ""Cannot connect to the Docker daemon""?
The Docker-in-Docker sidecar is still booting when the first docker command runs, so the socket is not ready.
How do I fix "Cannot connect to the Docker daemon"?
Wait for and target the daemon

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card