Skip to content
Latchkey

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?

Azure DevOps
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 1

Common 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.

Terminal
sudo systemctl enable --now docker
sudo usermod -aG docker "$(whoami)"
# restart the agent service so the new group applies

Use 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.

azure-pipelines.yml
pool:
  vmImage: 'ubuntu-latest'

How to prevent it

  • Install and enable Docker on self-hosted agent images.
  • Add the agent service account to the docker group.
  • Use Microsoft-hosted agents when a daemon is required and self-hosting is not.

Frequently asked questions

What causes ""Cannot connect to the Docker daemon""?
The agent image has the docker CLI but no daemon, or the daemon service is not started, so the socket does not exist.
How do I fix "Cannot connect to the Docker daemon"?
Ensure the Docker service is running and the agent user can reach the socket, then restart the agent so group membership takes effect.

Related guides

References

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