How to fix “dial unix /var/run/docker.sock: connect: permission denied” when group permissions seem correct?

南笙酒味 提交于 2019-12-03 01:19:19
sudo setfacl -m user:brandon:rw /var/run/docker.sock

doesn't require a restart and is more secure than usermod or chown

add the user to the docker group.

sudo usermod -aG docker $USER
sudo reboot

I did the quick fix and it worked immediately.

sudo chmod 777 /var/run/docker.sock

Specific to Ubuntu, there is a known issue with lightdm that removes secondary groups from the user as part of the GUI login. You can follow that issue here: https://bugs.launchpad.net/lightdm/+bug/1781418

You can try switching off of lightdm or apply the workaround mentioned in the bug report:

[Comment out the below lines from /etc/pam.d/lightdm:]

auth optional pam_kwallet.so
auth optional pam_kwallet5.so

Temporary options include logging into your machine with something like an ssh or su -l command, or running the newgrp docker command. These will only affect the current shell and would need to be done again with each new terminal.


Outside of this issue, the general commands to give a user direct access to the docker socket (and therefore root access to the host) are:

sudo usermod -aG docker $(id -un) # you can often use $USER in place of the id command
newgrp docker # affects the current shell, logging out should affect all shells
Jogabell

I run:

sudo docker run -it -p 8889:8888 -v /home/Documents/pa1:/home/ucsddse230/work ucsddse230/cse255-dse230 /bin/bash

and it work for me, given:

ucsddse230@50f69cc7cb0a:~/work$ 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!