Docker Desktop WSL2 integration stopped working


I started seeing the error “cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?” when trying to run docker commands in a WSL2 Ubuntu instance integrated with the Docker Desktop application running on Windows.

I have determined the root cause to be missing /var/run/docker.sock and /var/run/docker-cli.sock socket files in my Ubuntu instance.

My main question: Why doesn’t disabling/enabling Docker Desktop for the Ubuntu instance or re-installing Docker Desktop cause the WSL2 Integration to be re-set-up properly (i.e., the *.sock files to be re-generated)?


I’ve had docker desktop integration with my WSL2 Ubuntu instance working for months, and it mysteriously stopped working yesterday. This may be related to updates to Ubuntu or Docker Desktop - I’m not exactly sure what happened that caused the issue to surface.

I should also mention that my setup was the culmination of some trial-and-error, so I’m not sure that every best-practice was followed. I may have tried to install docker directly on the Ubuntu instance at some point, and not completely cleaned that up.

Failed Resolution Steps

Disable/enable Docker Desktop integration with WSL Instance

This did not seem to have any effect, and the *.sock files were not regenerated.

Reinstall Docker Desktop

Same as above

Switch default shell from zsh to bash, and reinstall Docker Desktop

Same as above


Install new Ubuntu instance on WSL

After installing a new WSL2 Ubuntu instance and enabling Docker Desktop integration with it, everything works fine. I can see the generated /var/run/docker.sock and /var/run/docker-cli.sock socket files in the new distribution.

Sym link existing docker.sock file

If I sym link /mnt/wsl/docker-desktop/shared-sockets/guest-services/docker.sock to /var/run/docker.sock, my docker commands start working again. I’m not sure that everything works after this workaround yet, just the operations I routinely perform.

Environment Information

Docker Desktop version: 4.12.0
Windows version: Windows 11 Home, Version 10.0.22000 Build 22000
WSL2 Ubuntu Version: 20.04.4 LTS
Default Shell in Ubuntu: zsh (this seemed to cause some issues reported by others)

This breaks on reboot - my coworker suspects that the docker.sock file is deleted on shutdown, which also deletes the sym link. I won’t pursue this workaround long term for this reason