🎓 A1Learner
🔍
0 of 50 lessons completed

Fix "Permission Denied"

"Permission denied" means the user cannot talk to the daemon socket. The fix is group membership, and the step guides skip is logging out and back in.

The error, reproduced

A user outside the docker group sees the real error.

docker ps

Add the user to the group

This command adds the user to the docker group.

sudo usermod -aG docker your-name

Join the group now

This command starts a shell with the new group.

newgrp docker

Example

docker ps

Key points

  • Socket: the file Docker uses to talk between the client and the daemon.
  • The socket belongs to the docker group, so only its members can use it.
  • Add your user with sudo usermod -aG docker your-name.
  • Group changes need a fresh login session, so log out and back in.
  • Use newgrp docker to join the group in the current terminal instead.
  • Test with docker ps. It lists containers when the fix works.

In this example, docker ps runs after the user joins the docker group and starts a fresh login session. The command lists containers instead of refusing. The fresh session is the step that makes the group change take effect.

Note

sudo docker ps works around the error, but it does not fix the permission.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

After adding a user to the docker group, what makes it take effect?