我想在 Docker 容器中运行 Windows 可执行文件。
我无法在 Linux Docker 中运行 Windows 容器:
$ docker run --rm microsoft/nanoserver
Unable to find image 'microsoft/nanoserver:latest' locally
latest: Pulling from microsoft/nanoserver
bce2fbc256ea: Pulling fs layer
b1b0c61be11f: Pulling fs layer
docker: image operating system "windows" cannot be used on this platform.
我尝试运行 Windows 10 VM 并在其中安装适用于 Windows 的 docker。安装顺利,但启动 docker 时出现此错误:
Unable to start: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: 'MobyLinuxVM' failed to start.
Failed to start the virtual machine 'MobyLinuxVM' because one of the Hyper-V components is not running.
'MobyLinuxVM' failed to start. (Virtual machine ID E8803091-3163-4906-8547-F3422532D501)
The Virtual Machine Management Service failed to start the virtual machine 'MobyLinuxVM' because one of the Hyper-V components is not running (Virtual machine ID E8803091-3163-4906-8547-F3422532D501).
at Start-MobyLinuxVM, <No file>: line 300
at <ScriptBlock>, <No file>: line 395
at Docker.Core.Pipe.NamedPipeClient.Send(String action, Object[] parameters) in C:\gopath\src\github.com\docker\pinata\win\src\Docker.Core\pipe\NamedPipeClient.cs:line 36
at Docker.Actions.DoStart(SynchronizationContext syncCtx, Boolean showWelcomeWindow, Boolean executeAfterStartCleanup) in C:\gopath\src\github.com\docker\pinata\win\src\Docker.Windows\Actions.cs:line 77
at Docker.Actions.<>c__DisplayClass16_0.<Start>b__0() in C:\gopath\src\github.com\docker\pinata\win\src\Docker.Windows\Actions.cs:line 61
at Docker.WPF.TaskQueue.<>c__DisplayClass19_0.<.ctor>b__1() in C:\gopath\src\github.com\docker\pinata\win\src\Docker.WPF\TaskQueue.cs:line 59
我已经验证 hyper-v 确实已启用。
是否可以让运行 Windows VM 的 Linux 主机运行 docker 以在容器中运行 Windows 可执行文件,或者我是否试图做一些不可能的事情?
答案1
您的第二个问题(“MobyLinuxVM”无法启动)可以通过在 powershell 中运行此命令来解决,这对我很有帮助。使用 64/32 位 powershell,就像您的 windows 一样。然后重新启动。
bcdedit /set hypervisorlaunchtype Auto
资源 (https://forums.docker.com/t/mobylinuxvm-failed-to-start/15175/7)