How to Fix GitLab CI Docker Socket Connection Error in CI Jobs
GitLab CI jobs fail with a 'Cannot connect to the Docker daemon at unix:///var/run/docker.sock' error when the DOCKER_HOST environment variable is not set, causing the Docker client to look for a local socket that does not exist inside the job container. The Docker daemon runs in a separate docker:dind service container, so the job container finds nothing listening on the local socket. The fix requires setting DOCKER_HOST to tcp://docker:2376 and keeping TLS-related variables consistent, using port 2376 when TLS certificates are configured and port 2375 only when TLS is explicitly disabled. A misconfigured or missing dind service — often due to the runner lacking privileged mode in its config — can also trigger the same error even when DOCKER_HOST is correctly set. This error is distinct from the tcp://docker:2375 variant, which points to a reachability or TLS mismatch issue rather than a missing DOCKER_HOST setting.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in