I am trying to use Docker CLI without sudo
ing every command.
For context, I am new to Linux. I've used Linux on a DigitalOcean server for about 30 hours total. This is my first Linux laptop. It is on Ubuntu 22.04.
Anyway, I'm pretty sure the common solutions aren't working because they presume sudo usermod -aG docker $USER
will give Docker the same permissions as my logged in user. But I still have to write sudo
before commands, so giving Docker the same permissions I have (without writing sudo
first) doesn't change anything.
To show my research I've visited the three following pages and a dozen more I won't list that say the same thing
cannot connect to Docker daemon socket without sudo
Allow non-root user to use some Docker commands
How can I use docker without sudo?
https://docs.docker.com/engine/install/linux-postinstall/
The summary of the advice is
sudo groupadd docker
sudo usermod -aG docker $USER
// then one of: "newgrp docker" | "reboot" | log out and back in
docker run hello-world
but when I do docker run hello-world
I get
docker: Cannot connect to the Docker daemon at unix:///home/rlm/.docker/desktop/docker.sock. Is the docker daemon running?.
This tells me sudo was still necessary to run docker because sudo
before the prev cmd still works.
So what do I have to do to make these steps work for me? Do I have to elevate the account I use for my laptop (Im the only user) to root so that giving Docker my permissions removes need for sudo
? I don't want my typical logged in user (even if its me) to be able to run just any command without sudo
in front of it. That seems bad to me.
id
after doing one of these? Isdocker
listed as one of your groups? – muru Jun 27 '22 at 02:49id
is:uid=1000(abc) gid=1000(pluto) groups=1000(pluto),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),122(lpadmin),134(lxd),135(sambashare),1001(docker)
– plutownium Jun 27 '22 at 05:28pluto
is a previous account I used before changing my username.abc
is my current account1001
is unusual for Docker's gid. When you install Docker, it should set up a system group for itself with gid less than1000
. How did you install Docker? – muru Jun 27 '22 at 05:34postinst
file ofdocker-ce
, which does have a command adding thedocker
group if it doesn't exist, so I think something went wrong with your install. Best purge the packages you have installed right now and re-install it afresh. – muru Jun 28 '22 at 01:57