Docker still requires sudo after adding my user to the docker group
Asked by
CedarMoon42
I'm running Ubuntu 26.04 LTS with Docker Engine installed without Docker Desktop. Every Docker command fails unless I prefix it with sudo. I tried `sudo usermod -aG docker $USER`, which seemed to work only in the terminal where I ran it. Logging out and rebooting did not fix the problem. What should I check to make Docker work as my normal user?
Answers
First verify that the group exists and that your current account is actually a member: run `getent group docker` and `groups`. If `docker` is missing from the group list, add the account explicitly with `sudo usermod -aG docker "$USER"`, then completely log out of your graphical session and log back in. A reboot is normally unnecessary, but simply opening another terminal may not refresh the group membership.
Reply to this answer
For a quick test in the current shell, run `newgrp docker`, then try `docker ps`. If that works, the issue was just that the shell had the old group membership. You can also check the socket permissions with `ls -l /var/run/docker.sock`; it should normally belong to the `docker` group. Donโt run `apt upgrade` or change unrelated permissions as a fix.
Reply to this answer
Be aware that membership in the `docker` group effectively gives a user root-level control over the host, because containers can be used to access the Docker daemon with high privileges. If that security tradeoff is unacceptable, look into Dockerโs rootless mode instead. Otherwise, confirm the group membership and restart your login session rather than using `sudo -i` as a workaround.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions