Console9

Docker: permission denied while trying to connect to the Docker daemon socket

Fix the Docker daemon socket permission error by adding your user to the docker group.

Docker produces "permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock" when the current user is not in the docker group.

What Causes This Error

The Docker daemon socket ( /var/run/docker.sock) is owned by root and the docker group. Non-root users without docker group membership cannot access the socket.

How to Fix

  1. Add the current user to the docker group:
sudo usermod -aG docker $USER
  1. Log out and log back in for the group change to take effect. Verify with:
groups
docker ps

The groups command should include docker. The docker ps command should work without sudo.