8

Host system is Archlinux. I want to develop .NET 4.6.1 app that needs to run Windows docker containers. So I run Win10 under VirtualBox. Then I install Docker inside that Win10 to run Windows docker containers. Linux -> VirtualBox -> Win10 -> Docker -> Windows docker container -> app to run.

Or more specifically, does VirtualBox support WSL 2 virtualization of Windows 10 (available since May 2020 update)?

In my VM setup on VirtualBox I check "Enable Nested VT-x/AMD-V", "Hyper-V" under paravirtualization and "Enable Nested Paging". Then I run my Win10 Pro installation. Speccy shows "Virtualization: Supported, Enabled". WSL 2 installed and running as well as Hyper-V and Virtual Machine Platform features. When I run Docker it fails with the error below.

System.InvalidOperationException:
Failed to deploy distro docker-desktop to C:\Users\WinUser\AppData\Local\Docker\wsl\distro: exit code: -1
 stdout: Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.
For information please visit https://aka.ms/wsl2-install

 stderr: 
   at Docker.Core.WslShortLivedCommandResult.LogAndThrowIfUnexpectedExitCode(String prefix, ILogger log, Int32 expectedExitCode) in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.Core\WslCommand.cs:line 119
   at Docker.Engines.WSL2.WSL2Provisioning.<DeployDistroAsync>d__16.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\WSL2\WSL2Provisioning.cs:line 142
--- 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__6.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\WSL2\WSL2Provisioning.cs:line 44
--- 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__23.MoveNext() in C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.Desktop\Engines\WSL2\LinuxWSL2Engine.cs:line 91
--- 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\stable-2.3.x\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\stable-2.3.x\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\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\StateMachines\StartTransition.cs:line 92

enter image description here

UPDATE. When I choose for VirtualBox machine KVM or Hyper-V for paravirtualization Docker reports that virtualization disabled. Task Manager under Windows shows that it is a virtual machine. When I choose None for paravirtualization, Windows shows that it is not a virtual machine and virtualization enabled (in Task Manager) but Docker reports "hardware assisted virtualization and data execution protection must be enbled in the BIOS" (in Win those features enabled: Virtual Machine Platform, Hyper-V, WSL).

My machine is Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz

VirtualBox version is 6.1.10 r138449.

Under VMWare 15.5.6 it works (Win10 -> Docker).

Artyom
  • 3,507
  • 2
  • 34
  • 67
  • Why do you need *virtualbox* when you have *wsl2*? Either of them can be used to run docker, which of those are you trying to use? – isAif Jul 03 '20 at 16:37
  • @isAif Host system is Archlinux. I want to develop .NET 4.6.1 app that needs to run Windows docker containers. So I run Win10 under VirtualBox. Then I install Docker inside that Win10 to run Windows docker containers. Linux -> VirtualBox -> Win10 -> Docker -> Windows docker container -> app to run. – Artyom Jul 04 '20 at 09:44
  • did you try using a different virtual machine software –  Jul 04 '20 at 09:50
  • Yes, VMWare works OK. Don't understand why downvotes. – Artyom Jul 04 '20 at 10:11
  • @Artyom your question was not clear previously. This edit makes is better, upvoted. – isAif Jul 08 '20 at 21:46
  • docker > Windows > VirtualBox > Linux . WOW are you trying to run docker on windows which is running on virtualBox and the host is Linux ? Why god Why ? – Dupinder Singh Jul 09 '20 at 18:16
  • Are you using `windows container` instead of on `Linux container` which is by default – Dupinder Singh Jul 09 '20 at 18:18
  • Just explain your problem, and what you have done so far, that would be enough to help you – Dupinder Singh Jul 09 '20 at 18:20
  • @DupinderSingh The issue is to develop dotnet app that uses Docker Windows containers (.net 4.6.1). I have Linux. – Artyom Jul 10 '20 at 16:34
  • @Artyom have a look to this post https://stackoverflow.com/a/42185265/5108695 This will help you better. – Dupinder Singh Jul 10 '20 at 19:46
  • @Artyom I think you will find a batter approach there in above mentioned answer – Dupinder Singh Jul 10 '20 at 19:48
  • 1
    @DupinderSingh Thanks. Read this already. This question is about new WSL 2 – Artyom Jul 11 '20 at 10:12
  • is there a way to get this question opened again? I have the same problem of getting WSL2 up and running on a Virtual Windows 10 box in virtualbox. The question is clear and on topic if this is your problem. Can we get it opened again or be told where to ask instead? – Guidhouse Jun 10 '21 at 08:17

1 Answers1

1

Docker for Windows require Hyper-V to be enabled as it makes Mobylinux there to run linux based containers and when it is enabled you can't run VMWare Workstation or Virtual Box.

If you want to run Docker on a VM then uncheck Hyper-V box and create a VM of required Linux (eg. ArchLinux, centOS etc.) and then install Docker on the said Linux VM to run/deploy containers.

To run Windows container you have to change settings of docker from tray icons and select setting that allow windows native containers, See Image to change to windows containers. After this you can deploy windows container like here.

You may also look this thread.

saad-ameer
  • 65
  • 4
  • 1
    Didn't understand. I can use Hyper-V in Windows when I run it in VMWare (it works there). Also I didn't understand why to create a VM of Linux on Windows 10 which runs in VirtualBox that runs on Linux (wtf?). The question is how to run windows docker containers. I will down vote this answer. – Artyom Jul 13 '20 at 10:40