Skip to main content

Docker · 5 common causes

permission denied: /var/run/docker.sock

Updated

Your user is not allowed to talk to the Docker daemon's socket.

The exact message

$ docker ps
permission denied while trying to connect to the Docker daemon socket at
unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.45/containers/json":
dial unix /var/run/docker.sock: connect: permission denied

Paths, line numbers and stack frames differ on every machine, and the wording is tightened between versions. The part that identifies the problem is permission denied: /var/run/docker.sock.

How to fix it

Cause 1 of 5

Your Linux user is not in the docker group.

sudo usermod -aG docker $USER, then log out and back in — or run newgrp docker in the current shell — so the new group takes effect. Know the trade-off before you do it: membership of the docker group is equivalent to root on that host, because anyone in it can start a container that mounts the whole filesystem.

Cause 2 of 5

You would rather not grant root-equivalent access.

Use rootless Docker, installed with dockerd-rootless-setuptool.sh install, or Podman, which runs containers as your own user with no daemon at all. On a shared or sensitive machine this is the better answer, not a compromise.

Cause 3 of 5

The daemon is not running.

Check with systemctl status docker and start it with sudo systemctl start docker. On macOS and Windows, start Docker Desktop — the socket exists but nothing is answering behind it.

Cause 4 of 5

A CI job or a container needs access to the socket.

Mounting /var/run/docker.sock into a container gives that container full control of the host, so anything it runs is effectively root. Prefer a rootless builder, a dedicated build service, or Docker-in-Docker with a scoped runner; if you must mount it, tightly control what runs inside.

Cause 5 of 5

You just want the one command to work.

sudo docker ... runs, but it leaves root-owned files behind in bind-mounted project directories and hides the setup problem. Fix the group membership or move to rootless instead of making sudo the habit. Never run chmod 666 /var/run/docker.sock — that hands every local account root on the machine.

Stopping it coming back

Decide once per machine how Docker is accessed — group membership on a personal box, rootless on anything shared — and put it in the provisioning script so nobody reaches for chmod under time pressure.

permission denied: /var/run/docker.sock — common questions

Why is the docker group considered root-equivalent?
Because a container can bind-mount the host's root filesystem and run as root inside. Anyone who can create containers can therefore read or modify anything on the host. It is a documented property of the design, not a bug.
Does this affect Docker Desktop on macOS or Windows?
Not in this form. Desktop runs the daemon inside a VM and handles the socket for you, so this message on those platforms almost always means Docker Desktop is not running.
Is rootless Docker a drop-in replacement?
Nearly. Most workflows are unchanged, but binding ports below 1024 needs extra configuration, some storage drivers and network modes differ, and performance can vary. Test your stack on it before switching a whole team.

Test the fix before you paste it back

Reproducing the failure in a scratch file is usually faster than editing the real one. AltF Code is a free in-browser editor with real syntax highlighting for HTML, CSS, JavaScript, TypeScript, Python, SQL and JSON, and it runs HTML, CSS and JavaScript live in a preview panel. No install and no sign-up.

Open the editor