我有一台 Windows Server 2019 机器(版本 1809,操作系统版本 17763.2237),我在其上使用此脚本安装了 Docker 引擎
Install-WindowsFeature -Name Hyper-V, Containers -IncludeAllSubFeature -IncludeManagementTools
Install-PackageProvider -Name NuGet -Force
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider -Force -RequiredVersion 20.10.7
Restart-Computer
$configfile =@"
{
"experimental":true
}
"@
$configfile | Out-File -FilePath c:\ProgramData\docker\config\daemon.json -Encoding ascii -Force
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine") # Linux containers
$lcowZipFile = "$env:TEMP\release.zip"
(New-Object Net.WebClient).DownloadFile('https://github.com/linuxkit/lcow/releases/download/v4.14.35-v0.3.9/release.zip', $lcowZipFile)
Expand-Archive -LiteralPath "$lcowZipFile" -DestinationPath "$Env:ProgramFiles\Linux Containers" -Force
del $lcowZipFile
Restart-Service Docker
Set-Service Docker -startuptype automatic
我可以检查 Linux 容器是否可以在我的 Docker 引擎上运行,因为下面的命令成功了
PS> docker run --rm -it alpine
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (windows/amd64) and no specific platform was requested
/ #
现在我有这个Dockerfile
FROM mcr.microsoft.com/dotnet/sdk:3.1-alpine AS build
WORKDIR /src
RUN ls
我正在尝试使用下面的命令构建它,但我遇到了一个我不知道如何修复的错误
PS > docker build .
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (windows/amd64) and no specific platform was requested
/ # exit
PS F:\DO\azA\_work\4\s> docker build .
Sending build context to Docker daemon 9.413MB
Step 1/3 : FROM mcr.microsoft.com/dotnet/sdk:3.1-alpine AS build
---> cf7d8740a8b7
Step 2/3 : WORKDIR /src
---> Using cache
---> 5298d93605e3
Step 3/3 : RUN ls
---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (windows/amd64) and no specific platform was requested
---> Running in 1eafc89176d2
The command '/bin/sh -c ls' returned a non-zero code: 4294967295: failed to shutdown container: container 1eafc89176d28b787add843351ba36caff0448b6618ec6d664ee04bbe58edb1a encountered an error during hcsshim::System::waitBackground: failure in a Windows system call: The virtual machine or container with the specified identifier is not running. (0xc0370110): subsequent terminate failed container 1eafc89176d28b787add843351ba36caff0448b6618ec6d664ee04bbe58edb1a encountered an error during hcsshim::System::waitBackground: failure in a Windows system call: The virtual machine or container with the specified identifier is not running. (0xc0370110)
如果我使用mcr.microsoft.com/dotnet/sdk:3.1-buster
图像而不是 alpine 的,也会出现同样的问题。
所以RUN
命令成功了(我的意思是,它只是一个ls
命令!)但 Docker 将其视为错误并且由于某种我不明白的原因而失败。问题可能出在哪里?