DEV Community

Vincent Tommi
Vincent Tommi

Posted on

Fixing Docker "Permission Denied" Error After Adding User to Docker Group

If you're encountering a "permission denied" error when trying to run Docker commands without sudo, even after adding your user to the Docker group, you're not alone. This issue usually stems from the fact that the group change hasn’t taken effect yet.

Problem
You’ve added your user to the Docker group with the following command:

sudo usermod -aG docker $USER
Enter fullscreen mode Exit fullscreen mode

However, when you run a Docker command like:

docker run hello-world
Enter fullscreen mode Exit fullscreen mode

You still get a "permission denied" error. Running the groups command shows your user is not yet part of the docker group, even though the usermod command completed successfully.

Example groupsoutput:

vinny : adm cdrom sudo dip plugdev users lpadmin
Enter fullscreen mode Exit fullscreen mode

So even though the command succeeded, you're still getting a “permission denied” error.

** Why It Happens**
When you add your user to a group using usermod, the change doesn’t apply to your current session. Your session needs to be refreshed (via logout/login) to pick up the new group membership

** The Fix**
Follow these steps:

Log out of your current session.

Log back in.

Open a terminal and run:

groups
Enter fullscreen mode Exit fullscreen mode

You should now see:

vinny : adm cdrom sudo dip plugdev users lpadmin docker
Enter fullscreen mode Exit fullscreen mode

Now run:

docker run hello-world
Enter fullscreen mode Exit fullscreen mode

It should work — no more permission errors!

Still Not Working?
If you're still getting errors after logging out and back in, double-check:

Does the docker group exist?

getent group docker
Enter fullscreen mode Exit fullscreen mode

If it doesn’t return anything, Docker may not be installed correctly.

Did the group assignment actually work?

sudo usermod -aG docker $USER
Enter fullscreen mode Exit fullscreen mode

Then log out and log back in again, just to be safe.

Conclusion
Docker permission errors after installation are common, especially when trying to run containers without sudo. Fortunately, the fix is simple: ensure your user is added to the docker group and log out and back in for the change to take effect.

By confirming your group membership and verifying with docker run hello-world, you’ll know everything is set up correctly.

Top comments (0)