Azure Pipelines "Cannot connect to the Docker daemon"
The docker client ran but could not reach a daemon socket. Microsoft-hosted Linux agents run Docker, but self-hosted agents do not unless Docker is installed and the agent user can access the socket.
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?
##[error]The process '/usr/bin/docker' failed with exit code 1Common causes
No Docker daemon on a self-hosted agent
The agent image has the docker CLI but no daemon, or the daemon service is not started, so the socket does not exist.
The agent user cannot access the socket
The daemon runs but the account the agent runs as is not in the docker group, so it is denied on /var/run/docker.sock.
How to fix it
Start the daemon and grant socket access
Ensure the Docker service is running and the agent user can reach the socket, then restart the agent so group membership takes effect.
sudo systemctl enable --now docker
sudo usermod -aG docker "$(whoami)"
# restart the agent service so the new group appliesUse a hosted agent that runs Docker
Microsoft-hosted ubuntu-latest agents run a Docker daemon out of the box; switch the pool if you do not need self-hosted.
pool:
vmImage: 'ubuntu-latest'How to prevent it
- Install and enable Docker on self-hosted agent images.
- Add the agent service account to the
dockergroup. - Use Microsoft-hosted agents when a daemon is required and self-hosting is not.