Running a Docker container root less without sudo - lmmx/devnotes GitHub Wiki

Through reading a guide to a new Docker container for teaching the SCIP optimisation libary, I learnt that

You probably do not want to run containers as root, therefore you might want to follow the post-install instructions

which currently advise:

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

and then try docker run with your container of choice without sudo.

If you already ran Docker with sudo you can fix it by either deleting the ~/.docker/ directory or just chowning it

sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
sudo chmod g+rwx "$HOME/.docker" -R

I tried this and discovered I don't actually have a ~/.docker/ directory so not sure if this always applies...

Some commands still require sudo (e.g. docker info, docker ps, docker cp), but docker run no longer requires sudo.

However, the docs note that docker still has root access in this setup.

For a root-less (and also daemon-less) alternative see Podman