for-win icon indicating copy to clipboard operation
for-win copied to clipboard

[WSL2] Docker startup fails with "wsl exited with code -1"

Open verglor opened this issue 7 years ago • 65 comments

  • [x] I have tried with the latest version of my channel (Stable or Edge)
  • [x] I have uploaded Diagnostics
  • Diagnostics ID: 83925FF1-D3EE-4CBF-A54A-68AC6D60F69F/20191202151149

Expected behavior

Docker engine should start in default WSL 2 distribution.

Actual behavior

Docker engine fails to start with the following error:

wsl exited with code -1. Stderr is:


   at Docker.Backend.ContainerEngine.WslEngine.DeployDistro(String name, String source, String destinationDir)
   at Docker.Backend.ContainerEngine.WslEngine.DoStart(Settings settings, String daemonOptions, Credential credential)
   at Docker.Backend.ContainerEngine.WslEngine.Start(Settings settings, String daemonOptions, Credential credential, Boolean retry)
   at Docker.Backend.ContainerEngine.WslEngine.Start(Settings settings, String daemonOptions, Credential credential, Boolean retry)
   at Docker.Backend.ContainerEngine.WslEngine.Start(Settings settings, String daemonOptions, Credential credential)
   at Docker.Backend.BackendNamedPipeServer.<Run>b__8_2(Object[] args)
   at Docker.Core.Pipe.NamedPipeServer.<>c__DisplayClass9_0.<Register>b__0(Object[] parameters)
   at Docker.Core.Pipe.NamedPipeServer.RunAction(String action, Object[] parameters)

Essentially the same as issue #5097 which is closed but the provided workaround (reinstalling WSL distribution) is neither working nor acceptable.

Information

  • Windows Version: 10.0.19033.1
  • Docker Desktop Version: 2.1.6.1
  • Are you running inside a virtualized Windows e.g. on a cloud server or on a mac VM: No
>wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-18.04    Running         2

verglor avatar Dec 02 '19 15:12 verglor

Can you try in powershell (as current user, not elevated):

cd ~/
mkdir docker-desktop-test
wsl --import docker-desktop-test .\docker-desktop-test\ 'C:\Program Files\Docker\Docker\resources\wsl\wsl-bootstrap.tar' --version=2

and report the result of this invocation ?

simonferquel avatar Dec 02 '19 15:12 simonferquel

@simonferquel I'm getting the same error from 2.1.6.1. I ran your commands above as my regular user, and I got no output - the wsl command appeared to execute successfully, there was no output, and Powershell went back to the prompt.

eblount avatar Dec 02 '19 20:12 eblount

@simonferquel I have the diagnostics .zip file. Let me know how to send it if you want it, please.

eblount avatar Dec 02 '19 21:12 eblount

Unfortunately 2.1.6.1 does not capture detailed output from wsl.exe (because wsl.exe sometimes send errors on stderr, sometimes stdout, sometimes in utf8 and sometimes in utf16 depending on the context). Next build will help us diagnose these errors and get a better understanding. I'll send you a link to a custom (not-production ready) build tomorrow. If you have time to try to run it and run a diagnostic with it if it fails, I' d be very grateful!

simonferquel avatar Dec 02 '19 22:12 simonferquel

@verglor, @eblount here is the "experimental build" for you to test: https://download-stage.docker.com/win/edge/41367/Docker%20Desktop%20Installer.exe (diagnostics coming from this build are much more detailed, and even the bug report window should present the output of the wsl commands we issue in both utf8 and utf16)

simonferquel avatar Dec 03 '19 08:12 simonferquel

Hi, @simonferquel, after installing "experimental build" 2.1.7.0 the error changed to:

Failed to deploy distro docker-desktop to C:\Users\jako\AppData\Local\Docker\wsl\distro: exit code: -1
 stdout(utf8): The operation timed out because a response was not received from the virtual machine or container.
 stdout(unicode): The operation timed out because a response was not received from the virtual machine or container.

  stderr (utf8): 
  stderr (unicode): 

   at Docker.Backend.ContainerEngine.WslEngine.WslOneShotResult.LogAndThrowIfUnexpectedExitCode(String prefix, ILogger log, Int32 expectedExitCode)
   at Docker.Backend.ContainerEngine.WslEngine.DeployDistro(String name, String source, String destinationDir)
   at Docker.Backend.ContainerEngine.WslEngine.DoStart(Settings settings, String daemonOptions, Credential credential)
   at Docker.Backend.ContainerEngine.WslEngine.Start(Settings settings, String daemonOptions, Credential credential, Boolean retry)
   at Docker.Backend.ContainerEngine.WslEngine.Start(Settings settings, String daemonOptions, Credential credential, Boolean retry)
   at Docker.Backend.ContainerEngine.WslEngine.Start(Settings settings, String daemonOptions, Credential credential)
   at Docker.Backend.BackendNamedPipeServer.<Run>b__8_2(Object[] args)
   at Docker.Core.Pipe.NamedPipeServer.<>c__DisplayClass9_0.<Register>b__0(Object[] parameters)
   at Docker.Core.Pipe.NamedPipeServer.RunAction(String action, Object[] parameters)

New diagnostic ID: 83925FF1-D3EE-4CBF-A54A-68AC6D60F69F/20191203122331

Result of invoking wsl --import docker-desktop-test .\docker-desktop-test\ 'C:\Program Files\Docker\Docker\resources\wsl\wsl-bootstrap.tar' --version=2 is still empty. (I have unregistered previous docker-desktop-test before running it)

verglor avatar Dec 03 '19 12:12 verglor

Do commands such as wsl -l -v succeed ?

simonferquel avatar Dec 03 '19 12:12 simonferquel

@simonferquel - Yes:

> wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu-18.04           Running         2
  docker-desktop-test    Stopped         2

verglor avatar Dec 03 '19 12:12 verglor

Can you check if C:\Users\jako\AppData\Local\Docker\wsl\distro is empty ?

simonferquel avatar Dec 03 '19 12:12 simonferquel

@simonferquel - Yes, it's empty

verglor avatar Dec 03 '19 12:12 verglor

Hmm, can you try to run wsl --import docker-desktop C:\Users\jako\AppData\Local\Docker\wsl\distro 'C:\Program Files\Docker\Docker\resources\wsl\wsl-bootstrap.tar' --version=2? and if it fails:

mkdir c:\Users\jako\custom-docker-desktop
wsl --import docker-desktop c:\Users\jako\custom-docker-desktop 'C:\Program Files\Docker\Docker\resources\wsl\wsl-bootstrap.tar' --version=2

and restart docker-desktop ?

simonferquel avatar Dec 03 '19 12:12 simonferquel

@simonferquel

C:\Users\jako> wsl --import docker-desktop C:\Users\jako\AppData\Local\Docker\wsl\distro 'C:\Program Files\Docker\Docker\resources\wsl\wsl-bootstrap.tar' --version=2
The operation timed out because a response was not received from the virtual machine or container.
C:\Users\jako> mkdir c:\Users\jako\custom-docker-desktop


    Directory: C:\Users\jako


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----       3. 12. 2019     13:54                custom-docker-desktop


C:\Users\jako> wsl --import docker-desktop c:\Users\jako\custom-docker-desktop 'C:\Program Files\Docker\Docker\resources\wsl\wsl-bootstrap.tar' --version=2
C:\Users\jako> wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu-18.04           Running         2
  docker-desktop         Running         2
  docker-desktop-test    Stopped         2

After restarting docker desktop, first line of error changed to Failed to deploy distro docker-desktop-data to C:\Users\jako\AppData\Local\Docker\wsl\data: exit code: -1

New diagnostic ID: 83925FF1-D3EE-4CBF-A54A-68AC6D60F69F/20191203130148

verglor avatar Dec 03 '19 13:12 verglor

Can you check in windows explorer if C:\Users\jako\AppData\Local\Docker\wsl\distro has compress or encrypt attributes ? (right click, properties, advanced an check the 2 attributes at the bottom of the window)

simonferquel avatar Dec 03 '19 13:12 simonferquel

It had compress attribute, but it does not work even after I disabled compression on whole %LOCALAPPDATA%\Docker folder and subfolders...

I even tried it with newly created %LOCALAPPDATA%\Docker\wsl\distro2 and it works - only %LOCALAPPDATA%\Docker\wsl\distro has problem.

verglor avatar Dec 03 '19 13:12 verglor

@simonferquel - It's working now ! I needed to restart computer after disabling compression on %LOCALAPPDATA%\Docker.

verglor avatar Dec 03 '19 13:12 verglor

Ok, nice to know. I'll make sure we disable compression/encryption on our distro deployment folders. Thanks!

simonferquel avatar Dec 03 '19 13:12 simonferquel

I tried to reenable compression on %LOCALAPPDATA%\Docker folder and error came back, so it is definitely the compression problem.

verglor avatar Dec 03 '19 13:12 verglor

@simonferquel I was late to the party this morning, so I decided to just try disabling compression on AppData\Local\Docker, and that worked fine for 2.1.6.1! It did require a restart, as @verglor said.

eblount avatar Dec 03 '19 15:12 eblount

@simonferquel Is it actually possible to prevent Windows to automatically compress specific folder without disabling compression globally ?

verglor avatar Dec 03 '19 17:12 verglor

I think that once you explicitly disable compression on a folder, it won't recompress it

simonferquel avatar Dec 03 '19 17:12 simonferquel