I am using Docker Desktop for Windows with WSL2 backend on Windows 11 Enterprise 23H2. My default WSL2 distro is Ubuntu 22.04.
When running docker ps in the WSL2 shell, I am getting the error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. Executing the same command in PowerShell works.
I have used Docker Desktop for quite a while and haven’t encountered this issue before v4.37.1, so to me it seems to be an issue related to this version? Downgrading to v4.36.0 solves the issue, but then auto update upgrades to v4.37.1 again.
In short, you need the WSL2 integration enabled in Docker Desktop for the chosen WSL2 distro and make sure you don’t install any components of Docker inside the WSL distro directly. I also have a blogpost about this error message which might help to figure out what your issue could be
Thanks for your answer! I read your blog post. While I still couldn’t fix my issue, I can provide you with some more details:
When I install Docker Desktop v4.36.0 (on Windows), the file /var/run/docker.sock exists on WSL (as well as docker-cli.sock and docker-desktop-prox-pid).
When rebooting my computer, Docker Desktop usually updates automatically and /var/run/docker.sock doesn’t exist any more (the other two files are also gone).
The same happens when I uninstall Docker Desktop and install v4.37.1 or v4.38.0 from scratch: /var/run/docker.sock doesn’t exist.
Any idea why /var/run/docker.sock doesn’t exist anymore for these newer Docker Desktop version and how to deal with this issue?
Some additional information: docker context ls returns the following in ubuntu shell:
Here is the output of docker context ls in PowerShell:
Since I have the latest version (4.38.0) on Windows and the socket exists, it is probably not be a general issue. On the other hand, I was recently lucky enough to not experience any issue that other users did.
What I can think is maybe the WSL2 integration feature is disabled in your Docker Desktop when you update it. I’m not sure why it would happen, or why the docker command would exist, but if the config changed and the automatic update fails at some point, it could be a possible reason. So first check if the WSL integration is still enabled and the required distribution is selected (Settings » Resources » WSL integration).
Also please, share the output of the following command executed in the WSL distribution
Sorry, it’s hard to keep up with the topics for me recently, but if you could not solve it yet, then you can try to disable it and reenable it. If it doesn’t help, check the logs of Docker Desktop
How did you uninstall? Docker has a guide to remove everything including folders that the uninstaller might leave there.
To be honest, it actually annoys me that I don’t know the reason and there is something that my blogpost can’t explain either But I don’t know what else I can suggest at the moment
There is an open issue which is about a missing exe on Windows
Can you run the docker command on Windows? If not, you can comment on GitHub too. If you can run the docker command, you can try to search for other issues or open a new issue for your case.
I can run the docker command both from Windows and from WSL. However, the docker deamon is reachable only from Windows (as mentioned above, I get an Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? error when running docker ps in the WSL2 shell).
Disabling and reenabling the WSL integration via Docker Desktop settings solves the issue! However, the fix is only temporary and inconsistent, meaning that
Usually, after restarting my computer, the same problem occurs again.
Changing the WSL integration doesn’t always work. Often, Docker Desktop is stuck in “shut down mode” forever when clicking “Apply & restart”.
Let me know if you have any further ideas. Otherwise, I will try the clean uninstall at some point, but I don’t currently want to lose all my images and containers.