Docker Permission Denied
The current user doesn't have permission to run Docker commands.
Explanation
Docker permission denied occurs when the user running Docker commands is not in the docker group or doesn't have the necessary permissions to communicate with the Docker daemon. By default, only the root user can run Docker commands. The Docker daemon socket (/var/run/docker.sock) is owned by root, so non-root users need to be added to the docker group. This error typically shows "permission denied while trying to connect to the Docker daemon socket".
Common Causes
- User not in docker group
- Docker daemon not running
- Socket permissions incorrect
- Using rootless Docker without setup
- Docker Desktop not running
Solution
Add your user to the docker group: sudo usermod -aG docker \$USER. Then log out and log back in for the group change to take effect. Alternatively, run Docker commands with sudo (not recommended for regular use). Check that the Docker daemon is running: sudo systemctl status docker. Verify the socket permissions: ls -la /var/run/docker.sock. For rootless Docker, follow the rootless installation guide. In Docker Desktop, ensure the application is running with proper permissions.
Code Example
# This fails with permission denied
docker ps
# Got permission denied while trying to connect to the Docker daemon socket
# Fix: add user to docker group
sudo usermod -aG docker $USER
newgrp docker # apply group change
# Then retry
docker ps
# Alternative: run with sudo (not recommended)
sudo docker ps
# Check Docker daemon status
sudo systemctl status docker
# Check socket permissions
ls -la /var/run/docker.sock
# srw-rw---- 1 root docker 0 ... /var/run/docker.sock
# For rootless Docker
# Follow: https://docs.docker.com/engine/security/rootless/
dockerd-rootless-setuptool.sh install
# Verify Docker is accessible
docker info # should work without sudo
Error Information
Language
bash
Framework
docker
Difficulty
Beginner
Views
14
Related Errors
503
DevOps
Service Unavailable (503)
The server is temporarily unable to handle requests due to overload or maintenance.
EADDRINUSE
DevOps
Port Already in Use
The application cannot start because the required port is already occupied by another process.
ENOSPC
DevOps
Out of Disk Space
The system or application ran out of disk space.
CrashLoopBackOff
DevOps
Kubernetes CrashLoopBackOff
A container is repeatedly crashing and restarting in Kubernetes.