How to Fix Docker Error: Permission Denied Socket
Quick Answer: Docker permission denied error occurs when your user lacks access to the Docker daemon socket. Add your user to the docker group or use sudo to run Docker commands.
What Causes This Error
- User not added to docker group
- Docker daemon socket has restrictive permissions
- Docker service not running or not started
- SELinux or AppArmor blocking socket access
- Docker installation incomplete or corrupted
- User session not refreshed after group addition
- Docker daemon configuration restricting access
Step-by-Step Fixes
Fix 1: Add User to Docker Group
Run: sudo usermod -aG docker $USER,Log out and log back in,Or run: newgrp docker,Verify with: docker ps,Test without sudo
Fix 2: Check Docker Service Status
Run: sudo systemctl status docker,If stopped, run: sudo systemctl start docker,Enable on boot: sudo systemctl enable docker,Verify status,Test Docker command
Fix 3: Fix Socket Permissions
Check socket: ls -l /var/run/docker.sock,Fix permissions: sudo chmod 666 /var/run/docker.sock,Or restart Docker daemon,Verify permissions,Test Docker access
Fix 4: Disable SELinux or AppArmor
Check status: getenforce or aa-status,Temporarily disable for testing,If it works, configure exceptions,Permanently configure if needed,Restart Docker daemon
Fix 5: Use Sudo as Workaround
Run: sudo docker [command],Or create alias: alias docker="sudo docker",Add to ~/.bashrc or ~/.zshrc,Source the file,Test the alias
FAQs
Q:
A:
Q:
A:
Q:
A:
Q:
A:
Q:
A: