The infamous Docker permission error looks like this:
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get \"http://localhost/v1.30/info\": dial unix /var/run/docker.sock: connect: permission denied
Docker talks to its daemon through a Unix socket at /var/run/docker.sock
. That socket is owned by root, and unless you're root or in the docker
group, you get told to fuck off. That's it. No mystery networking bullshit - just Unix file permissions doing their job.
Docker's client-server architecture relies on Unix socket communication
The Root Cause: Socket Permissions
When Docker starts, it creates the /var/run/docker.sock
socket file with these permissions:
ls -la /var/run/docker.sock
## Output: srw-rw---- 1 root docker 0 Aug 31 10:15 /var/run/docker.sock
The srw-rw----
permissions mean:
- s: Socket file type
- rw-: Owner (root) has read/write access
- rw-: Group (docker) has read/write access
- ---: Everyone else has no access
If your user isn't in the docker
group, you can't access the socket. Simple as that.
How You Installed Docker Matters (Unfortunately)
APT Installation: The only sane way. Docker Engine via apt creates the docker
group for you. Add yourself and call it done.
Snap Installation: Pain in the dick. Snap runs everything in a security sandbox, so normal group tricks need extra bullshit to work.
Docker Desktop: Finally works on Ubuntu 24.04, but earlier versions were a total shitshow with AppArmor throwing tantrums. Still having issues on 24.04? You need to disable some kernel security theater.
Common Permission Scenarios
Fresh Install: You installed Docker but never added your user to the docker group. Every command needs sudo
.
After System Update: Ubuntu updates sometimes reset file permissions or change how snap packages handle group membership.
Multiple Installation Methods: You have both snap and apt versions installed, causing conflicts. This is surprisingly common.
WSL2 on Windows: Docker Desktop in WSL2 has additional permission complexities related to Windows user mapping.
The Security Reality Check
Here's the thing: adding yourself to the docker
group basically gives you root access. Docker's own docs admit this. You can mount the host filesystem, run privileged containers, access any file - you're root without the sudo
ceremony.
Dev laptop? Who gives a shit. Production server? Maybe don't do this.
If you're paranoid, use rootless Docker or keep typing sudo docker
everywhere. But let's be honest - most of us just want Docker to work without constantly typing our password.
Why Those Stack Overflow \"Fixes\" Suck
You'll find Stack Overflow answers suggesting sudo chmod 777 /var/run/docker.sock
or sudo chown $USER /var/run/docker.sock
. Don't do this shit. Works for 5 minutes until:
- You reboot
- Docker restarts
- System updates
- You look at it wrong
The daemon recreates that socket file every startup and nukes your brilliant permission hack. Only group membership survives restarts.
Detection: Confirming You Have Permission Issues
Before trying fixes, confirm the issue. I learned this the hard way after wasting 2 hours thinking Docker was completely broken:
## Check if Docker daemon is running (do this first!)
sudo systemctl status docker
## Check current user's group membership
groups $USER
## Check socket permissions
ls -la /var/run/docker.sock
## Test Docker access - this will fail with permission denied
docker info
War story: On a fresh Ubuntu 22.04 installation, I ran docker run hello-world
and got slammed with the permission error. Spent way too long thinking the Docker service was broken because the error message mentions "dial unix" which sounds like a connection problem, not permissions. The key insight: if sudo systemctl status docker
shows "active (running)" but docker info
fails, it's 100% a permissions issue, not a service problem.
If Docker is running but docker info
fails with permission errors, and your user isn't in the docker
group, you've found the problem.