Docker on WSL2 in Windows 2004

Documenting a couple of pitfalls, and how I've set up Docker Desktop under WSL2

Following Unregister and reinstall a distribution, I had run wsl --unregister Ubuntu-20.04

On starting Docker Desktop, I would see a crash, which included these log lines:

System.InvalidOperationException:
Failed to deploy distro docker-desktop to C:\Users\Nick\AppData\Local\Docker\wsl\distro: exit code: -1
stdout: The system cannot find the path specified.

Even downloading and reinstalling the latest version of Docker (2.3.0.3) didn't fix it.

Finally, on watching a video by Nick Janetakis on A Linux Dev Environment on Windows with WSL 2, Docker Desktop and More, I got inspired about Linux development under Windows, using WSL2

Within Docker Desktop, I navigated to Resources / WSL Integration, and saw:

You don't have any WSL 2 distro. Please convert a WSL 1 distro to WSL 2, or install a new distro and it will appear here.

So, back to my new-found friend, the Windows Terminal

wsl -l -v

Gave the output:

  NAME            STATE           VERSION
* Legacy Stopped 1
Ubuntu-20.04 Stopped 1
Ubuntu-18.04 Stopped 1

Crucially, passing the -v flag, we see that these are all WSL1 images. The conversion from WSL1 to 2 should be possible with:

wsl --set-version Ubuntu-20.04 2

Output:

Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
The system cannot find the path specified.

So, we're back to a "can't find the path" type error

At this point, I'm happy to terminate my problematic instances, so I run:

wsl --unregister Ubuntu-20.04
wsl --unregister Ubuntu-18.04

And then set any future WSL distros to use version 2, with:

wsl --set-default-version 2

Following one of the other recommendations in the Nick Janetakis video, I opted to install the latest release of Power Toys

After a reboot for good measure, the output of wsl -l -v is:

  NAME      STATE           VERSION
* Legacy Stopped 1

With PowerRun installed, typing Alt + Space meant that I could open the Microsoft Store easily

PowerRun search store

Once installed, I click Launch

Launch

But I get our very similar error again:

Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80070003
Error: 0x80070003 The system cannot find the path specified.

Press any key to continue...

I removed the .wslconfig I had been experimenting with, and got a different error:

Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0xc03a001a
Error: 0xc03a001a The requested operation could not be completed due to a virtual disk system limitation. Virtual hard disk files must be uncompressed and unencrypted and must not be sparse.

As a side note, the issue was still present even after un-installing and re-installing.

This blog post was very helpful in diagnosing the issue of disk Compression being enabled.

My path was C:\Users\Nick\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc

Path to Ubuntu 20.04

Once I turned off the Compression, I was able to Launch Ubuntu 20.04

Then set my default:

wsl --set-default Ubuntu-20.04

Then back to Docker Desktop

Although I've set Ubuntu-20.04 as the default WSL distro, I prefer to be doubly sure, and toggle on:

Enabled integation with additional distros: Ubuntu-20.04

Docker Desktop WSL Integration

Now the output of wsl -l -v

  NAME                   STATE           VERSION
* Ubuntu-20.04 Running 2
docker-desktop-data Running 2
Legacy Stopped 1
docker-desktop Running 2

Tagged

🙏🙏🙏

Since you've made it this far, sharing this article on your favorite social media network would be highly appreciated 💖! For feedback, please ping me on Twitter.

Published