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

后端 未结 7 1465
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-30 10:01

I\'m suddenly having issues after an update of Ubuntu 18.04: previously I\'ve used docker without issue on the system, but suddenly I cannot. As far as I can tell, the permissio

7条回答
  •  南方客
    南方客 (楼主)
    2021-01-30 10:51

    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
    

提交回复
热议问题