🎉 DevOps Interview Prep Bundle is live — 1000+ Q&A across 20 topicsGet it →
All Fixes
Today I Fixed

Docker: Permission Denied on /var/run/docker.sock

dockerMay 27, 202610 minutes to fixdockerlinuxtroubleshooting

The Problem

New team member ran docker ps on a Linux server and got:

permission denied while trying to connect to the Docker daemon socket 
at unix:///var/run/docker.sock

What Happened

The user wasn't in the docker group. On Linux, the Docker socket is owned by root:docker. If your user isn't in the docker group, you can't connect.

The Fix

bash
# Add user to the docker group
sudo usermod -aG docker $USER
 
# Apply group change without logging out
newgrp docker
 
# Verify it worked
docker ps

If newgrp doesn't work, log out and back in — the group membership needs to refresh.

Check Group Membership

bash
# See all groups for current user
groups
 
# Should include 'docker'
# ubuntu adm cdrom sudo dip plugdev lpadmin sambashare docker

In CI/CD (if this happens in a pipeline)

bash
# In Dockerfile or CI runner setup
RUN usermod -aG docker jenkins  # or whatever the CI user is
 
# Or run the docker command with sudo (not recommended)
# Or use Docker-in-Docker (dind) properly with the right socket mount

Security Note

Adding a user to the docker group is essentially giving them root access. The docker socket has full control over the host. On production servers, be deliberate about who's in this group.