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

 

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


 stderr: 
   at Docker.ApiServices.WSL2.WslShortLivedCommandResult.LogAndThrowIfUnexpectedExitCode(String prefix, ILogger log, Int32 expectedExitCode) in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.ApiServices\WSL2\WslCommand.cs:line 146
   at Docker.Engines.WSL2.WSL2Provisioning.<DeployDistroAsync>d__17.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\WSL2\WSL2Provisioning.cs:line 169
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Docker.Engines.WSL2.WSL2Provisioning.<ProvisionAsync>d__8.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\WSL2\WSL2Provisioning.cs:line 78
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Docker.Engines.WSL2.LinuxWSL2Engine.<DoStartAsync>d__25.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\WSL2\LinuxWSL2Engine.cs:line 99
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Docker.ApiServices.StateMachines.TaskExtensions.<WrapAsyncInCancellationException>d__0.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\TaskExtensions.cs:line 29
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Docker.ApiServices.StateMachines.StartTransition.<DoRunAsync>d__5.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\StartTransition.cs:line 67
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Docker.ApiServices.StateMachines.StartTransition.<DoRunAsync>d__5.MoveNext() in C:\workspaces\PR-15138\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\StartTransition.cs:line 92

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.

Related

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments