Is a missing docker.sock file a bug?

The Docker integration for PyCharm stopped working for me. I don’t know why because to my knowledge nothing has changed since it was working. PyCharm gives me the error “Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?”, but otherwise Docker works, e.g. the command-line is functional and I can connect to containers. Full details are in this StackOverflow post.

Most of the StackOverflow resolutions for similar problems involve changing the permissions on the /var/run/docker.sock file. However, there is no /var/run/docker.sock file on my machine.

Is the missing docker.sock file a bug?

  • Docker version 20.10.22, build 3a2c30b
  • Mac OSX Ventura 13.1
  • Python Community Edition 2021.2.3

If I remember correctly, that file was removed in a Docker Desktop version and restored in another version. I am not sure, I just remember something that I read before. That file is just a symbolic link.

 »  ls -l /var/run/docker.sock
lrwxr-xr-x@ 1 root  daemon  33 Jan 28 02:37 /var/run/docker.sock -> /Users/ta/.docker/run/docker.sock

So it points to

$HOME/.docker/run/docker.sock
 »  ls -l $HOME/.docker/run/docker.sock
srwxr-xr-x@ 1 ta  staff  0 Jan 29 14:54 /Users/ta/.docker/run/docker.sock

Depending on the current docker context Docker uses the symbolic link or the socket in your home folder with different owner and group.

docker context ls

The default context’s socket is /var/run/docker.sock and this is what PyCharm reads when you choose “Docker for Mac” in the conection settings (Right click on the Docker menu in PyCharm » “Edit Configuration”).

It looks like it doesn’t depend on the current context. I don’t know why that socket is missing. It could be a bug, but I don’t know the bug of what. IT could be Docker or an other application. I have the latest macOS, Docker Desktop and I still have that file. Some applications like Rancher Desktop can replace that symbolic link to point to their own socket file. When you uninstall an application like that, it is possible that it removes the symbolic link without restoring the original link pointing to the socket of Docker Desktop.

You can restore it by recreating the symbolic link this way:

sudo ln -s $HOME/.docker/run/docker.sock /var/run/docker.sock

update:

Okay, I didn’t have the latest macOS, since it is 13.2 now, but I have the same version as you and I don’t think macOS would remove any socket that is not related to the operating system itself…

3 Likes

Thanks. I think this is my problem.

I don’t have sudo on this machine, so I have to wait to get an admin to try this fix, but in the meantime what should the permissions on /var/run/docker.sock be? The permissions on the socket under my home directory are

/Users/bill.mcneill % ll .docker/run/docker.sock
srwxr-xr-x  1 bill.mcneill  staff  0 Jan 29 11:52 .docker/run/docker.sock

Is this correct for the /var/run/docker.sock, or do I have to ask the admin to also run a chown for me?

No, but it will automatically get the right permissios when you create the link as root. At least it did when I ran the command I mentioned. And the right owner and group is in my first code block. The owner is root, the group is daemon.