Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Docker on Windows on VirtualBox on Linux? [closed]

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).

like image 838
Artyom Avatar asked Jul 03 '20 16:07

Artyom


1 Answers

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.

like image 166
saad-ameer Avatar answered Oct 24 '22 07:10

saad-ameer