Failed to deploy distro docker desktop Please enable the Virtual Machine Platform Windows feature

개요

Android 개발환경을 설정하며 의도치 않게 WSL2의 구동에 영향을 미치는 환경설정을 변경하였습니다.

Show
C:\Windows\system32>wsl 가상 컴퓨터 플랫폼 Windows 기능을 사용하도록 설정하고 BIOS에서 가상화가 사용하도록 설정되어 있는지 확인 하세요.

위 오류 문구를 통해 검색하여, 웹에 제시되어 있는 해결법에 따라 Linux 용 Windows 하위 시스템, 가상 머신 플랫폼 을 비활성화, 재부팅, 활성화, 재부팅하였으나 개선되지 않았습니다.

그래서 검색어를 변경하여 아래와 같이 영문 오류 메시지를 이용하여 검색하여 해결방법을 찾았고 이를 공유합니다.

Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.

해결

문제 확인 및 진단

# 관리자 권한으로 cmd 실행 # 진단 C:\Windows\system32>bcdedit Windows 부팅 관리자 -------------------- identifier {bootmgr} device partition=\Device\HarddiskVolume2 path \EFI\Microsoft\Boot\bootmgfw.efi description Windows Boot Manager locale ko-KR inherit {globalsettings} default {current} resumeobject {fa42bf7d-49fa-11e9-b4b3-8caa000d495c} displayorder {current} bootsequence {0cb3b571-2f2e-4343-a879-d86a476d7215} toolsdisplayorder {memdiag} timeout 30 Windows 부팅 로더 ------------------- identifier {current} device partition=C: path \Windows\system32\winload.efi description Windows 10 locale ko-KR inherit {bootloadersettings} recoverysequence {fa42bf7f-49fa-11e9-b4b3-8caa000d495c} displaymessageoverride Recovery recoveryenabled Yes isolatedcontext Yes allowedinmemorysettings 0x15000075 osdevice partition=C: systemroot \Windows resumeobject {fa42bf7d-49fa-11e9-b4b3-8caa000d495c} nx OptIn bootmenupolicy Standard hypervisorlaunchtype Off

hypervisorlaunchtype 항목이 off로 되어 있는 것이 문제라고 합니다.

조치

아래와 같이 hypervisorlaunchtype 항목을 auto 로 변경한 후, 재부팅합니다.

C:\Windows\system32>bcdedit /set hypervisorlaunchtype auto

참고

  • Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.
  • WSL2 ERROR [가상 컴퓨터 플랫폼 Windows 기능을 사용하도록 설정하고 BIOS에서 가상화가 사용하도록 설정되어 있는지 확인하세요.]
  • WSL CODE 4294967295 오류와 해결

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:

Failed to deploy distro docker desktop Please enable the Virtual Machine Platform Windows feature

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:

Failed to deploy distro docker desktop Please enable the Virtual Machine Platform Windows feature

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

  1. remove all my WSL2 flavours this way:
    Failed to deploy distro docker desktop Please enable the Virtual Machine Platform Windows feature
  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”

Failed to deploy distro docker desktop Please enable the Virtual Machine Platform Windows feature

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

Downgrading WSL2 to WSL1 won’t help.