On Docker's documentation pages, all example commands are shown without sudo
, like this one:
docker ps
On Ubuntu, the binary is called docker.io
. It also does not work without sudo:
sudo docker.io ps
How can I configure Docker so that I don't need to prefix every Docker command with sudo?
Best Answer
Good news: the new docker (version 19.03 (currently experimental)) will be able to run rootless negating the problems that can occur using a root user. No more messing with elevated permissions, root and anything that might open up your machine when you did not want to.
Video about this from [DockerCon 2019] Hardening Docker daemon with Rootless mode
As of docker 19.3 this is obsolete (and more dangerous than need be):
The docker manual has this to say about it:
Important to read: post-installation steps for Linux (it also links to Docker Daemon Attack Surface details).
Add the docker group if it doesn't already exist:
Add the connected user "$USER" to the docker group. Change the user name to match your preferred user if you do not want to use your current user:
Either do a
newgrp docker
or log out/in to activate the changes to groups.You can use
to check if you can run docker without sudo.