Issue
I've installed Docker on an Ubuntu Server 18.04.
I received permissions error when trying to run docker commands, so I run this command:
sudo chmod 666 /var/run/docker.sock
Now I found that the tidy solution is to follow next steeps:
- Create the docker group.
sudo groupadd docker
- Add your user to the docker group.
sudo usermod -aG docker ${USER}
- You would need to loog out and log back in so that your group membership is re-evaluated or type the following command:
su -s ${USER}
As I'm new with Linux management, I'm not sure on how to revert the last chmod command.
Is there a way to do it?
Solution
The default permissions on /var/run/docker.sock
is generally owned by user root
and group docker
, with mode 0660 (read/write permissions for owner and group, no permissions for others).
sudo chmod 0660 /var/run/docker.sock
Remember that anyone who can run any docker
command at all can trivially root the host
docker run --rm -it -v /:/host busybox vi /host/etc/sudoers
For a development system adding your normal user to the docker
group might be acceptable; if you have actual production-oriented data on the system, requiring sudo
might be more appropriate.
Answered By - David Maze Answer Checked By - Senaida (WPSolving Volunteer)