Docker 用于 Windows Docker 文件
Docker for Windows Dockerfile
我正在尝试使用 VSTS 构建代理为 Windows 容器创建一个 Docker 图像。我有以下 Docker 文件:
# escape=`
FROM microsoft/aspnetcore-build:2.0-nanoserver-sac2016
# Set up environment
ENV AGENT_VERSION 2.129.1
ENV AGENT_TYPE build
# Download/extract the VSTS agent software
RUN Invoke-WebRequest -UseBasicParsing
https://vstsagentpackage.azureedge.net/agent/${env:AGENT_VERSION}/vsts-agent-win-x64-${env:AGENT_VERSION}.zip -outfile agent.zip; `
Expand-Archive agent.zip; `
Remove-Item -Force agent.zip;
WORKDIR C:\agent
# Configure the agent and run it as a Windows service
# Users can pass "--deploymentGroup" to the "docker run" command if they want to run the agent as a deployment group (release) agent.
SHELL ["cmd", "/S", "/C"]
ENTRYPOINT C:\agent\config.cmd --unattended --auth pat --runAsService --addDeploymentGroupTags
我从 ENTRYPOINT
行收到这个非常令人困惑的错误:
-Sta : The term '-Sta' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Comman ...
+ ~~~~
+ CategoryInfo : ObjectNotFound: (-Sta:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
An error occurred: PowerShell is not installed. Minimum required version: 3.0
我查看了下载的 config.cmd
脚本,它在第 26 行有以下令人讨厌的语句:
powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$VerbosePreference = %VERBOSE_ARG% ; Get-ChildItem -LiteralPath '%~dp0' | ForEach-Object { Write-Verbose ('Unblock: {0}' -f $_.FullName) ; $_ } | Unblock-File | Out-Null ; Get-ChildItem -Recurse -LiteralPath '%~dp0bin', '%~dp0externals' | Where-Object { $_ -match '\.(ps1|psd1|psm1)$' } | ForEach-Object { Write-Verbose ('Unblock: {0}' -f $_.FullName) ; $_ } | Unblock-File | Out-Null ; Get-ChildItem -LiteralPath '%~dp0externals\vstsom', '%~dp0externals\vstshost' | Where-Object { $_ -match '\.(dll|exe)$' } | ForEach-Object { Write-Verbose ('Unblock: {0}' -f $_.FullName) ; $_ } | Unblock-File | Out-Null"
所以该行似乎是我的容器中发生故障的行,但我不知道为什么。 aspnetcore-build 映像 (Dockerfile) that I'm deriving from is itself derived from a microsoft/dotnet image (Dockerfile),它将 SHELL
设置为 powershell
,因此我知道容器中安装了 PowerShell。从 Docker 调用此 .cmd 脚本是否会导致某种语法错误?任何帮助将不胜感激!
有Windows个图片文件:vsts-agent-docker/windows/servercore/10.0.14393
它运行代理是这样的:
& .\bin\Agent.Listener.exe configure --unattended `
--agent "$env:VSTS_AGENT" `
--url "https://$env:VSTS_ACCOUNT.visualstudio.com" `
--auth PAT `
--token "$env:VSTS_TOKEN" `
--pool "$env:VSTS_POOL" `
--work "$env:VSTS_WORK" `
--replace
& .\bin\Agent.Listener.exe run
关于这张图片的使用方法:https://github.com/Microsoft/vsts-agent-docker/blob/master/README.md#how-to-use-these-images
我正在尝试使用 VSTS 构建代理为 Windows 容器创建一个 Docker 图像。我有以下 Docker 文件:
# escape=`
FROM microsoft/aspnetcore-build:2.0-nanoserver-sac2016
# Set up environment
ENV AGENT_VERSION 2.129.1
ENV AGENT_TYPE build
# Download/extract the VSTS agent software
RUN Invoke-WebRequest -UseBasicParsing
https://vstsagentpackage.azureedge.net/agent/${env:AGENT_VERSION}/vsts-agent-win-x64-${env:AGENT_VERSION}.zip -outfile agent.zip; `
Expand-Archive agent.zip; `
Remove-Item -Force agent.zip;
WORKDIR C:\agent
# Configure the agent and run it as a Windows service
# Users can pass "--deploymentGroup" to the "docker run" command if they want to run the agent as a deployment group (release) agent.
SHELL ["cmd", "/S", "/C"]
ENTRYPOINT C:\agent\config.cmd --unattended --auth pat --runAsService --addDeploymentGroupTags
我从 ENTRYPOINT
行收到这个非常令人困惑的错误:
-Sta : The term '-Sta' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Comman ...
+ ~~~~
+ CategoryInfo : ObjectNotFound: (-Sta:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
An error occurred: PowerShell is not installed. Minimum required version: 3.0
我查看了下载的 config.cmd
脚本,它在第 26 行有以下令人讨厌的语句:
powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$VerbosePreference = %VERBOSE_ARG% ; Get-ChildItem -LiteralPath '%~dp0' | ForEach-Object { Write-Verbose ('Unblock: {0}' -f $_.FullName) ; $_ } | Unblock-File | Out-Null ; Get-ChildItem -Recurse -LiteralPath '%~dp0bin', '%~dp0externals' | Where-Object { $_ -match '\.(ps1|psd1|psm1)$' } | ForEach-Object { Write-Verbose ('Unblock: {0}' -f $_.FullName) ; $_ } | Unblock-File | Out-Null ; Get-ChildItem -LiteralPath '%~dp0externals\vstsom', '%~dp0externals\vstshost' | Where-Object { $_ -match '\.(dll|exe)$' } | ForEach-Object { Write-Verbose ('Unblock: {0}' -f $_.FullName) ; $_ } | Unblock-File | Out-Null"
所以该行似乎是我的容器中发生故障的行,但我不知道为什么。 aspnetcore-build 映像 (Dockerfile) that I'm deriving from is itself derived from a microsoft/dotnet image (Dockerfile),它将 SHELL
设置为 powershell
,因此我知道容器中安装了 PowerShell。从 Docker 调用此 .cmd 脚本是否会导致某种语法错误?任何帮助将不胜感激!
有Windows个图片文件:vsts-agent-docker/windows/servercore/10.0.14393
它运行代理是这样的:
& .\bin\Agent.Listener.exe configure --unattended `
--agent "$env:VSTS_AGENT" `
--url "https://$env:VSTS_ACCOUNT.visualstudio.com" `
--auth PAT `
--token "$env:VSTS_TOKEN" `
--pool "$env:VSTS_POOL" `
--work "$env:VSTS_WORK" `
--replace
& .\bin\Agent.Listener.exe run
关于这张图片的使用方法:https://github.com/Microsoft/vsts-agent-docker/blob/master/README.md#how-to-use-these-images