How to fix WSL2 incompatibility with Docker

I like this blog. It took me just 1 article to drop all the attention I was paying for the SEO rules.

But let’s move on and try to understand this incompatibility between WSL2 and Docker.

Scenario

You might have been using virtualizations like Hyper-V, VMWare & Co (…no, not you VirtualBox) for a decent number of years now and suddenly Docker comes out and “…PUF…” , it’s such a game changer that you want to keep up with the technology shift.

If you like technology there is the chance that you have already installed Windows Subsystem for Linux and if you are an early adopter like myself you have probably left WSL1 for WSL2 because it’s definitely faster and your terminal doesn’t get stuck when using apt-get

And here comes the trouble: after the first installation everything looks smoothly and Docker is up and running. Then you go to bed because once again is midnight and they after when you wake up and fire up Docker this is what you get:

System.InvalidOperationException: Failed to deploy distro docker-desktop

 

You try to reboot the machine, reboot Docker, nothing works.

Ironically also your Linux bash doesn’t work.

Solution

The root cause is that Docker uses WSL2 and it has overwritten your previous WSL2 installation.

In fact if you run wsl -l -v you will see that both uses WSL2:

wsl -l -v docker

Is sad but in order to fix this issue I had to

  1. remove all my WSL2 flavours this way:
    Uninstall WSL2
  2. Then uninstall Docker
  3. Go to Control Panel > Programs > Programs and Features and disable Windows Subsystem for Linux
  4. Then reboot the machine to finalize everything.
  5. Log back in, enable once again Windows Subsystem for Linux and reinstall all my WSL2 flavours
  6. Now install Docker again but this time at this step untick “Install required Windows components for WSL 2”

Windows components for WSL2

..I know this is not a good news but this is how I fixed it.

Downgrading WSL2 to WSL1 won’t help.

Categories:

Leave a Reply

Your email address will not be published. Required fields are marked *