在 Windows Server 2019 上運行 dapr 遇到的 docker 問題


在 Windows Server 2019 上安裝 dapr ,安裝成功后有一段提示文字

Ensure that Docker Desktop is set to Linux containers mode when you run Dapr in self hosted mode.

開始時沒注意到這個提示,然后安裝 docker engine

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider

接着運行 dapr init ,報下面的錯誤

docker: no matching manifest for windows/amd64 10.0.17763 in the manifest list entries.

查找資料后得知 docker engine 默認是 Windows container 模式,解決上面的錯誤需要切換到 Linux container 模式,這時才注意到安裝 dapr 時的提示。

通過 docker desktop 切換到 Linux container 模式,但 docker engine 總是啟動失敗,報錯如下:

The Virtual Machine Management Service failed to start the virtual machine 'DockerDesktopVM' because one of the Hyper-V components is not running

折騰一陣,沒有解決,后來通過 Run Docker Containers on Windows Server 2019 知道原來需要安裝 preview 版 Docker EE。

通過下面的一系列 powershell 命令安裝 preview 版 Docker EE 之后,支持 Linux container 模式終於成功啟動。

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

Uninstall-Package -Name docker -ProviderName DockerMSFTProvider
Install-Module DockerProvider
Install-Package Docker -ProviderName DockerProvider -RequiredVersion preview
Restart-Computer -Force
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")
Restart-Service docker

但是運行 dapr init 出現新的錯誤

docker: failed to register layer: failed to start service utility VM (applydiff 88e57cc977280a42ef93829fad29a6ffbe1be1320278764f77575546056c1800): container 88e57cc977280a42ef93829fad29a6ffbe1be1320278764f77575546056c1800_svm encountered an error during CreateContainer: failure in a Windows system call: The virtual machine could not be started because a required feature is not installed. (0xc0370102) extra info: {"SystemType":"container","Name":"88e57cc977280a42ef93829fad29a6ffbe1be1320278764f77575546056c1800_svm","Layers":null,"HvPartition":true,"HvRuntime":{"ImagePath":"C:\Program Files\Linux Containers","LinuxInitrdFile":"initrd.img","LinuxKernelFile":"bootx64.efi"},"ContainerType":"linux","TerminateOnLastHandleClosed":true}.

運行 ubuntu 容器也是同樣的錯誤

docker run -it --rm ubuntu /bin/bash

又折騰一陣,通過 Azure VM Docker CreateContainer Error (0xc0370102) 知道原來需要雲服務器支持 Nested Virtualization,看來當前使用的百度雲服務器不支持。

換到阿里雲試試,阿里雲提供了專門的“Windows Server 2019 with Container 數據中心版”鏡像,用這個鏡像也未能成功運行 Linux container。

網上查了一下,目前好像只有微軟的 azure 與 google 的 gcd 支持 Nested Virtualization。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM