Home·Error messages

docker · Docker

The message

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

What it means

The docker command does nothing itself — it asks a daemon over that socket, and nothing answered. Either the daemon is not running, Docker Desktop has not finished starting on macOS or Windows, or on Linux your user is not in the docker group and may not open the socket; all three produce this one line. On Linux start it with sudo systemctl start docker; with Desktop, launch the app first. If it is the permission case, sudo usermod -aG docker $USER and a fresh login fix it — but be aware that group is effectively root-equivalent.

The fix

sudo systemctl start docker
Printed by
docker
Docker
12

Docker errors only become readable once you place them in a layer — the client failing to reach the daemon, the registry refusing you, a RUN failing during the build, and a container dying the instant it starts are four different problems — and for the build and run layers the line itself is not the reason: the reason is in the output of the command that was running inside, while the cost of each fix differs by layer too.

Reading an error message

  • Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
  • If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
  • Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
  • The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
  • Before pasting a fix, check what it throws away. Some of these cannot be undone.

Common questions

Q. What does “Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?” mean?

The docker command does nothing itself — it asks a daemon over that socket, and nothing answered. Either the daemon is not running, Docker Desktop has not finished starting on macOS or Windows, or on Linux your user is not in the docker group and may not open the socket; all three produce this one line. On Linux start it with sudo systemctl start docker; with Desktop, launch the app first. If it is the permission case, sudo usermod -aG docker $USER and a fresh login fix it — but be aware that group is effectively root-equivalent.

Q. How do I fix it?

sudo systemctl start docker — before running it, check the explanation above for what this command discards.

Q. Which tool prints this?

docker. It sits under Docker, and the message runs to 13 words.

Errors nearby