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
dockergroup.
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
- Add the current user to the
dockergroup:
sudo usermod -aG docker $USER- Log out and log back in for the group change to take effect. Verify with:
groups
docker psThe
groups command should include
docker. The
docker ps command should work without
sudo.