To use docker without sudo, you need to be in the group docker
.
Read the Docker docs: https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user
Here's what to do:
If it doesn't, you'll need it anyway, so just run:
sudo groupadd docker
You'll most likely get this response:
groupadd: group 'docker' already exists
sudo usermod -aG docker $USER
The variable USER stores your username in your current shell session.
If you want to add some other user, just replace $USER
string with their username.
3. Apply changes, by either starting a new shell session (e.g. logout and log back in via SSH) or by simply logging into the new group via:
newgrp docker
Now, you should be able to run docker commands without root privileges! :D