Docker: Manage / Run Docker Commands Without sudo

install-docker-ce-on-centos-7

In our previous article, we discussed Docker and how to install Docker CE on CentOS 7.  By default when you install Docker on Linux, you can only access the Docker daemon as the root user, or by using sudo. Adding "sudo" in front of each Docker command is tedious – to avoid this, add your user to the "docker" group.

In this article, we will see how to manage or run docker commands without sudo on linux.

Add a "docker" group and then add your user to it:

[devopstechie@localhost ~]$ sudo groupadd docker
[devopstechie@localhost ~]$ sudo usermod -aG docker $USER   # $USER = your username E.g. devopstechie

After logging back on, now can run docker commands without "sudo". and  also restart the Docker service without "sudo":

[devopstechie@localhost ~]$ systemctl start docker

Avinash Pawar

An automation enthusiast who presently working as DevOps Engineer.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle Plus

Avinash Pawar

An automation enthusiast who presently working as DevOps Engineer.