1

I am trying to run Docker commands without sudo user, but they are giving me below error:

I following the steps provided online: Created the docker group --> sudo groupadd docker

Add user to the docker group --> sudo usermod -aG docker $USER

restarted VM --> newgrp docker

sudo setfacl -m user:$USER:rw /var/run/docker.sock

restarted docker:

sudo systemctl daemon-reload`
sudo systemctl restart docker

I also tried modifying the visudo file and added my user privileges as below:

sudo visudo
anand   ALL=(ALL:ALL) ALL
anand ALL=(ALL) NOPASSWD: ALL

I even tried changing the owner of my /var/run/docker.sock file to my user. It was with root initially

srw-rw---- 1 root docker 0 Aug 2 12:37 /var/run/docker.sock

I changed owner to below:

srw-rw---- 1 anand anand 0 Aug  2 12:37 /var/run/docker.sock

Finally none of the options seem to work. Kindly suggest some options to fix this issue.

2
  • Can you please specify what error you are getting? Commented Aug 2, 2019 at 8:18
  • The "below error" seems to be missing from the question. Commented Aug 2, 2019 at 10:09

1 Answer 1

1

First, you need to check if your user (or user that you want to use with docker) is in docker group. For that, just run this command:

id -nG

If it says that user is in the docker group, then try again running this command if you want to add an active user:

sudo usermod -aG docker ${USER}

or run this if you want to add some other user:

sudo usermod -aG docker other_username

After you add a user to the group, you need to logout and then login again to apply new group changes.

Sign up to request clarification or add additional context in comments.

2 Comments

I already tried these commands. My user 'anand' has been added in the group and it is still giving this error after docker restart as well. anand@anand-ThinkPad-P51:~$ id -nG anand adm cdrom sudo dip plugdev lpadmin sambashare
I was able to resolve this issue by changing the owner and group of /var/run/docker.sock file as sudo chown anand:docker /var/run/docker.sock. I am now able to run docker commands without sudo also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.