GitLab CI DinD "Cannot connect to the Docker daemon at tcp://docker:2375" in CI
Your job runs Docker commands but the client cannot reach a daemon at tcp://docker:2375. Usually the docker:dind service is not declared, has not finished starting, or the TLS/port configuration does not match the daemon.
What this error means
A docker build/docker info step fails with "Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?".
Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?Common causes
No docker:dind service attached
Without a docker:dind service the docker hostname does not resolve to a running daemon.
TLS/port mismatch
Newer dind defaults to TLS on 2376; pointing the client at plaintext 2375 without disabling TLS fails the connection.
How to fix it
Declare the dind service and DOCKER_HOST
- Add the
docker:dindservice to the job. - Set
DOCKER_HOSTto the dind service and match the TLS setting. - Re-run the job.
build-image:
image: docker:27
services:
- docker:27-dind
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
script:
- docker infoUse TLS on 2376 instead
Keep TLS enabled and point the client at the TLS port with the generated certs.
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_CERT_PATH: "/certs/client"
DOCKER_TLS_VERIFY: 1How to prevent it
- Always pair Docker jobs with a matching
docker:dindservice. - Keep DOCKER_HOST and the TLS/port settings consistent.
- Pin matching docker and dind image versions.