Docker on wsl2 no longer says yes or no

Docker can't be used from wsl

I forgot the reason, but suddenly the docker command stopped working. Of course, docker-compose is the same.

Error message


ERROR: dial unix /mnt/wsl/docker-desktop/shared-sockets/guest-services/docker.sock: connect: no such file or directory

I think that the path part differs depending on the person, but I got this error. There is a symlink on wsl called /var/run/docker.sock, which points to a socket in the wsl distribution called docker-desktop, which somehow disappeared. I will. Restarting Docker or restarting wsl didn't help.

By the way, I could use the docker command from Power Shell. It seems that the connection from wsl to the docker daemon is just broken.

How to fix

Reference: ubuntu running under WSL2 not seeing Docker daemon at unix: ///var/run/docker.sock # 5096

When I started Docker Desktop with wsl integration enabled, I created symbolic links for various related files such as the socket in wsl, but it did not heal even if I restarted because they remained halfway. It seems that. So, delete all docker related files.

sudo find /usr -name "*docker*" -type l -exec rm {} +
sudo find /usr -name "*Docker*" -type l -exec rm {} +
sudo find /usr -name "*kube*" -type l -exec rm {} +
sudo rm /usr/share/doc/docker-ce-cli/changelog.Debian.gz
sudo rm /var/run/docker*

After executing the above command with wsl, restarting docker fixed it. It was good.

Recommended Posts

Docker on wsl2 no longer says yes or no
Docker installation on WSL2
Using Docker on Windows10 Home WSL2
Windows Docker: Disk pressure on WSL files
Introducing Docker Desktop for Windows on WSL2
Try putting Docker in ubuntu on WSL
Docker on Ubuntu18.04 on WSL2 and VSCode installation instructions
Operate Docker Desktop for Windows on Linux (WSL)
Liberty on Docker
Redmine on Docker
Easily build Redmine on Windows using WSL2 and Docker