Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 permissions look correct:

$ docker run hello-world docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.35/containers/create: dial unix /var/run/docker.sock: connect: permission denied. See 'docker run --help'. $ ls -last /var/run/docker.sock  0 srw-rw---- 1 root docker 0 Jul 14 09:10 /var/run/docker.sock $ whoami brandon $ cat /etc/group | grep docker docker:x:995:brandon nvidia-docker:x:994: 

EDIT:

Group information:

$ groups brandon $ groups brandon brandon : brandon adm cdrom sudo dip plugdev games lpadmin sambashare docker $ whoami brandon 

Update

Since the original post where I upgraded a system from 17.04 to 18.04, I've done two upgrades from 16.04 to 18.04, and neither of the later systems had the issue. So it might be something to do with the 17.04 to 18.04 upgrade process. I've yet to perform a fresh 18.04 installation.

like image 538
bbarker Avatar asked Jul 14 '18 19:07

bbarker


People also ask

How do I fix docker permission is denied issue?

If running elevated Docker commands does not fix the permission denied error, verify that your Docker Engine is running. Similar to running a docker command without the sudo command, a stopped Docker Engine triggers the permission denied error. How do you fix the error? By restarting your Docker engine.

Do you have permission to run docker?

In the default set up flow, Docker Desktop for Mac does not require root privileges for installation but does require root access to be granted on the first run. The first time that Docker Desktop is launched the user receives an admin prompt to grant permissions for a privileged helper service to be installed.

What is var run docker sock?

sock is basically the Unix socket the Docker daemon listens on by default. It is also a tool used to communicate with the Docker daemon from within a container. Sometimes, containers need to bind mount the /var/run/docker.


1 Answers

sudo setfacl --modify user:<user name or ID>:rw /var/run/docker.sock 

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

as @mirekphd pointed out, the user ID is required when the user name only exists inside the container, but not on the host.

like image 155
Nahshon paz Avatar answered Sep 20 '22 05:09

Nahshon paz