Docker容器不是运行Windows系统调用错误

Docker container not running with Windows system call error

我正在尝试 运行 Azure Pipelines 中的 dotnet/core/sdk 容器。为了让一切都井井有条,我构建了一个 PowerShell 脚本,它可以有效地拉取容器并将必要的文件放入其中,然后 运行 将其安装:

$compositeImage = "mcr.microsoft.com/dotnet/core/sdk:3.0.100-preview4-nanoserver-1809"
docker pull $compositeImage

$targetContainer = ""

Write-Host "Creating container for pre-provisioning..."

($targetContainer = docker create --name builder $compositeImage)

Write-Host $targetContainer

docker ps -a
Write-Host "Copying samples to container..."
$workPath = "C:\Users\dendeli\Documents\Expression"
$scriptPath = "C:\Users\dendeli\Downloads\test2\test2.ps1"

Write-Host "Samples path: " + $workPath
Write-Host "Script path:" + $scriptPath

Write-Host "Executing copy..."
docker cp $workPath builder:__samples

Write-Host "Executing script copy..."
docker cp $scriptPath builder:buildsamples.ps1

Write-Host "Committing changes..."
docker commit builder "mcr.microsoft.com/dotnet/core/sdk"

docker run --name newbuilder --rm "mcr.microsoft.com/dotnet/core/sdk" powershell

问题出现在最后,当我执行docker run。如果我排除要传递的命令 (powershell),它一切正常,我看到这个输出:

Microsoft Windows [Version 10.0.XYZ]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\>

但是,附加了命令后,我 运行 进入了拦截器 - 它出错了:

C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: container 879f2fff5aeaf19ace367d3f713242519238a96944b35b2598f2a3b6010a19fb encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF686739ADB: (caller: 00007FF6866EDF1A) Exception(2) tid(380) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
 Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"powershell","User":"ContainerUser","WorkingDirectory":"C:\","Environment":{"ASPNETCORE_URLS":"http://+:80","DOTNET_RUNNING_IN_CONTAINER":"true","DOTNET_USE_POLLING_FILE_WATCHER":"true","NUGET_XMLDOC_MODE":"skip"},"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}.

我在这里错过了什么?

C:\> docker container run -it --rm mcr.microsoft.com/dotnet/core/sdk:3.0.100-preview4-nanoserver-1803

Microsoft Windows [Version 10.0.17134.706]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\>powershell
'powershell' is not recognized as an internal or external command,
operable program or batch file.

对于 Powershell 5.1,您需要网络框架来 运行 它,这在托管 dotnet 核心的容器中没有意义。

pwsh有效(Powershell 核心)。

C:\>pwsh
PowerShell 6.2.0
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS C:\>