Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm Cannot Connect to Docker, thinks the Docker daemon is not running

The PyCharm interface to Docker has suddenly stopped working on my Mac. When I try to connect to Docker I get the error message "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?".

Docker appears to be working correctly. docker info returns reasonable results. The Docker Desktop is running. I can start a container through Docker Desktop and connect to it. Kibana works. The only thing that looks odd is that /var/run/docker.sock does not exist.

Is it a problem that docker.sock does not exist?

The PyCharm configuration for Docker looks like this:

enter image description here

I haven't changed it since everything worked.

A common solution suggested online it to change the permissions on the /var/run/docker.sock file, but obviously I can't do that. There is an assortment of things to try, but most of them require sudo and I don't have admin privileges on this machine. There is a Stack Overflow question that describes the same situation, but there the problem was that Docker could not be run without sudo, which is not the case here.

What is particularly strange is that this was working just a few days ago, and as far as I know nothing on the machine has changed. Same PyCharm setup, same Docker, same OS. I'm on

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

I have tried restarting the system.

Any ideas on what is broken?

like image 276
W.P. McNeill Avatar asked Oct 25 '25 08:10

W.P. McNeill


2 Answers

The problem was that /var/run/docker.sock did not exist.

More details are in this Docker support forum thread.

This fix was to create the following softlink:

ln -s ~/.docker/run/docker.sock /var/run/docker.sock
like image 136
W.P. McNeill Avatar answered Oct 27 '25 00:10

W.P. McNeill


You can create the socket file via Docker Desktop's settings.

Setting > Advanced > Allow the default Docker socket to be used

The description of the setting says

Creates /var/run/docker.sock which some third-party clients may use to communicate with Docker Desktop. Learn more

enter image description here

like image 21
ynn Avatar answered Oct 26 '25 22:10

ynn