How to Fix Docker Permission Denied on Debian 11


The Root Cause

On Debian 11, the Docker daemon runs as root and communicates via a Unix socket located at /var/run/docker.sock. By default, this socket is owned by the root user and the docker group, with permissions set such that only members of the docker group can interact with it without sudo. When a user attempts to execute docker commands without sudo and is not part of the docker group, they encounter a “Permission Denied” error because they lack the necessary access to the socket.

Quick Fix (CLI)

sudo usermod -aG docker $USER
newgrp docker

Configuration Check

For this specific “Docker Permission Denied” issue related to user permissions, there isn’t a Docker-specific configuration file (e.g., daemon.json, Dockerfile) to edit. The “configuration” change occurs at the operating system level, modifying user group membership. The usermod command in the Quick Fix updates the /etc/group file (and implicitly /etc/gshadow) by adding the current user to the docker group. No manual file editing is typically required or recommended for this change; the usermod utility handles it.

Verification

To confirm that the current user is now part of the docker group and can execute Docker commands without sudo:

id -nG
docker run hello-world