Quick answer
Run sudo usermod -aG docker $USER, then log out and back in (or run newgrp docker to skip the logout).
What's actually happening here
Docker runs as a daemon that listens on a Unix socket at /var/run/docker.sock. By default, that socket is owned by root:docker with permissions 660. So only root and members of the docker group can read/write to it. If your user isn't in that group, every docker ps or docker run command slaps you with a permission denied error.
This is by design — Docker doesn't want any random user talking to the daemon without explicit permission. The socket is the gateway to root-level container operations (like mounting filesystems or spawning privileged containers). So you can't just chmod it to 777; that'd be a security nightmare.
Fix steps
- Add your user to the docker group
Here,sudo usermod -aG docker $USERusermod -aGappends (note the-a— without it,-Greplaces your secondary groups entirely, which is bad) the user to thedockergroup. If you skip the-a, you'll lose access to other groups you're in (likesudo). I've seen that mistake lock people out of sudo. Don't skip it. - Log out and log back in
Group membership changes are applied at login time. If you don't log out, your current session still has the old groups. You can test withexit(or close your terminal) then log in againgroupsin a new terminal after logging back in — you should seedockerlisted. - Or skip the logout with
newgrp
This spawns a subshell with the new group. It's a workaround, not permanent. Runnewgrp dockerdocker psin that shell to confirm it works. - Verify the fix
If you see a list of running containers (or an empty table), it worked. If you still get the permission denied error, check that Docker daemon is actually running (docker pssudo systemctl status docker) or that the socket exists (ls -l /var/run/docker.sock).
If the main fix doesn't work
- Check if the docker group exists
If it doesn't, install Docker again — the package creates the group during installation. On Ubuntu/Debian, that'sgetent group dockersudo apt install docker.io. On Fedora,sudo dnf install docker-ce. - Manually create the group
Then add your user and restart Docker (sudo groupadd dockersudo systemctl restart docker). - Check the socket permissions
It should showls -l /var/run/docker.socksrw-rw---- 1 root docker. If it's something else (likeroot:rootor wrong permissions), something's misconfigured. Runsudo chown root:docker /var/run/docker.sockandsudo chmod 660 /var/run/docker.sockto fix it. But this is a symptom of a deeper issue — check your Docker configuration or restart the daemon.
Prevention tip
After adding yourself to the docker group, any user in that group can effectively run containers with root privileges (they can mount the host filesystem, for example). So only add trusted users. If you're on a shared system, consider using sudo for Docker commands instead — it's more audit-friendly. Or switch to rootless Docker mode (since Docker 19.03), which avoids the socket group issue entirely by running the daemon under your user's UID. That's the real long-term fix for multi-user environments.