How Do You Run Docker commands without sudo?

Problem scenario
For security reasons, you do not want to have to use "sudo" to elevate your privileges when you run docker commands.  What should you do?

1.  Run these commands as the user that will be able to run docker commands:
sudo groupadd docker
sudo gpasswd -a $USER docker
newgrp docker

2.  Install Docker.  See this posting if you need directions.

3.  Run these commands:
sudo systemctl enable docker
sudo systemctl start docker

4.  Reboot the server.  

5.  You are done.  Going forward you should be able to run docker commands without sudo.  You can test it by running this: docker run hello-world

Leave a comment

Your email address will not be published. Required fields are marked *