cannot run docker as non-privileged user. I added user to docker group with:
sudo groupadd -a -G docker $USER
I loggeg out and in again, still no success. I am running docker on a Ubuntu 21.10 system.
When you use "sudo" you are forking a new process as "root". So the $USER variable will be "root" and not your user.
Replace the $USER by the name of the user you are trying to add privileges.
sudo groupadd -a -G docker username_here
Finally, logout and login again, start a new terminal session and run "id" to check if the user now belongs to the docker group.
sudo
process is started, the variable $USER
, which is shell-specific, has already been replaced with its value. It’s certainly true that the environment variables change, but groupadd
does not use these.
id
to check whether that actually worked. Also please provide the entire error message you get when trying to rundocker run --rm -it hello-world
.