CircleCI "Cannot connect to the Docker daemon" in CI
A docker build or docker run step ran inside the Docker executor, which has no Docker daemon of its own. Without setup_remote_docker, there is no socket to connect to.
What this error means
A docker command fails with "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?".
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Is the docker daemon running?Common causes
No remote Docker in a Docker executor
The Docker executor runs your job inside a container with no daemon; docker commands need a separate remote Docker environment.
setup_remote_docker placed after the docker step
The remote Docker must be set up before any docker command, or the socket is not yet available.
How to fix it
Add setup_remote_docker before docker steps
- Insert
setup_remote_dockerearly in the job. - Run all docker commands after it.
- Pin a Docker version if you need a specific one.
jobs:
build:
docker: [{image: cimg/base:2024.01}]
steps:
- checkout
- setup_remote_docker
- run: docker build -t app .Use the machine executor instead
A machine executor provides a full Docker daemon natively, so no remote Docker is needed.
jobs:
build:
machine:
image: ubuntu-2204:current
steps:
- run: docker build -t app .How to prevent it
- Add
setup_remote_dockerwhenever the Docker executor runs docker commands. - Place it before the first docker step.
- Consider the machine executor for docker-heavy jobs.