Skip to content
Latchkey

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?".

GitLab Runner
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

  1. Add the docker:dind service to the job.
  2. Set DOCKER_HOST to the dind service and match the TLS setting.
  3. Re-run the job.
.gitlab-ci.yml
build-image:
  image: docker:27
  services:
    - docker:27-dind
  variables:
    DOCKER_HOST: tcp://docker:2375
    DOCKER_TLS_CERTDIR: ""
  script:
    - docker info

Use TLS on 2376 instead

Keep TLS enabled and point the client at the TLS port with the generated certs.

.gitlab-ci.yml
variables:
  DOCKER_HOST: tcp://docker:2376
  DOCKER_TLS_CERTDIR: "/certs"
  DOCKER_CERT_PATH: "/certs/client"
  DOCKER_TLS_VERIFY: 1

How to prevent it

  • Always pair Docker jobs with a matching docker:dind service.
  • Keep DOCKER_HOST and the TLS/port settings consistent.
  • Pin matching docker and dind image versions.

Frequently asked questions

What causes ""Cannot connect to the Docker daemon at tcp://docker:2375""?
Without a docker:dind service the docker hostname does not resolve to a running daemon.
How do I fix "Cannot connect to the Docker daemon at tcp://docker:2375"?
Declare the dind service and DOCKER_HOST

Related guides

References

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