Docker still requires sudo after adding my user to the docker group

0
0
Asked By CedarMoon42 On

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?

3 Answers

Answered By SilverKite308 On

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.

Answered By QuietHarbor19 On

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.

Answered By MapleOrbit7 On

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.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.