docker permissions ai_generated true

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

ID: docker/permission-denied-sock

Also available as: JSON · Markdown
95%Fix Rate
95%Confidence
67Evidence
2017-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
24 active
24 active

Root Cause

This error occurs when the current user does not have permission to access the Docker daemon socket. The standard fix is adding the user to the 'docker' group. This is one of the most common Docker setup errors on Linux and is almost always resolvable.

generic

Workarounds

  1. 95% success Add your user to the docker group
    sudo usermod -aG docker $USER && newgrp docker. You may need to log out and back in for the group change to take full effect. Verify with 'groups' command. Then test with 'docker ps'.

    Sources: https://docs.docker.com/engine/install/linux-postinstall/

  2. 80% success Use rootless Docker mode
    Install rootless Docker: 'dockerd-rootless-setuptool.sh install'. This runs the Docker daemon as a non-root user, eliminating the socket permission issue entirely. Requires uidmap package: 'sudo apt-get install uidmap'.

    Sources: https://docs.docker.com/engine/security/rootless/

Dead Ends

Common approaches that don't work:

  1. Running chmod 777 /var/run/docker.sock 55% fail

    This opens the Docker socket to all users on the system, which is a severe security vulnerability. The Docker daemon runs as root, so unrestricted socket access grants root-equivalent privileges to any local user. The permission also resets on Docker daemon restart.

  2. Prefixing every Docker command with sudo 55% fail

    Running Docker with sudo works as an immediate workaround but is not a long-term solution. It breaks IDE integrations, Docker Compose workflows, CI/CD scripts, and development tooling that expects Docker to work without sudo. It also trains users to run everything as root.

Error Chain

Frequently confused with: