我正在尝试在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]}.
我在这里想念什么?
答案 0 :(得分:1)
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,您将需要一个net框架来运行它,在托管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:\>