Skip to main content

2. Adding your user to docker group

Every single time, you want to run a docker command, you will have to sudo in front of it. This can get tiring and annoying when managing your server. Thus, you add your user to the docker group so you don't need to write sudo every time.

Checking docker group is created:

sudo groupadd docker

Then, add your user to the docker group (simply copy paste below command):

sudo usermod -aG docker $USER

To apply, changes to group, simply type logout and re-login via ssh.

Verify that you can run docker commands without sudo:

docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.

If you see the below output, everything is working perfectly:

dockerhelloworld.JPGdockerhelloworld.JPG