Docker not integrating with WSL2

I am at a complete loss as to why Docker Desktop is not integrating with my WSL2 distribution. I have tried lots of things (reinstalling/resetting) in various orders to no avail. The symptom is best summed up in the following picture:

As you can see, I have selected “Ubuntu” as a distro that I want the integration enabled for, but the docker command is not running docker… it is running some wrapper script that is not terribly helpful.

In all other respects, Docker seems to be working as long as I run the command from Windows PowerShell, but that is not where I need to run it from… I have a project checked out in my WSL2 distro, and need to be able to run Docker from there.

Any help would be greatly appreciated, as this is really holding me up.

I assume you tried to exit the WSL2 distribution and enter it again before you used the Docker commands. Did you?

Yeah, I tried various combinations in various orders of Uninstalling Docker Desktop/Rebooting/wsl --shutdown.

The WSL2 distro that I have is one I’ve had around for several months, so I might see about creating a second “blank” one to see if Docker Desktop can successfully “move into” that one. It’s not ideal, but it’s one more piece to try out I suppose.

After spinning up another WSL2 container (Debian), I was able to narrow down that the issue was that, in Ubuntu, my default shell was set to Fish, and Docker Desktop somehow wasn’t integrating correctly with that. It’s a bummer that I have to set my default shell back to bash, but I can work around that if it means having a working environment.

It is probably just a missing path in the fish shell. If Docker adds the path of the docker executable to the bashrc, that could be missing in fish and you can check how bashrc (global or user-level) or profile files look like and add the path to fish.

I don’t think that’s it: the Docker Desktop integration seems to do a few things:

  • Links several files to /usr/bin (/usr/bin/docker is a link to /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker)
  • Runs the following two programs (presumably, one of this creates /var/run/docker.socket):
    • /mnt/wsl/docker-desktop/docker-desktop-user-distro proxy ...
    • /docker serve ...

I looked at the various bash profile files and I do not believe they are mutated during the integration.

I see. I couldn’t check it at that moment and I still can’t so that was a guess, and it seems I was wrong.

I remember one case when integration didn’t work for me. I think I played with custom kernels so in that case I most likely broke something. I never solved it.