Reputation: 31
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.
Upvotes: 1
Views: 1696
Reputation: 126
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.
Upvotes: 1