如果我在自己的dockerfile中有此文件,它将成功:
但是如果我将其嵌入另一个dockerfile中,它将失败:
FROM openjdk:8-nanoserver as openjdk
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# Remoting versions can be found in Remoting sub-project changelog
# https://github.com/jenkinsci/remoting/blob/master/CHANGELOG.md
ENV SLAVE_FILENAME=slave.jar \
SLAVE_HASH_FILENAME=$SLAVE_FILENAME.sha1 \
REMOTING_VERSION=3.23
# Get the jenkins slave jnlp agent jar from public location
RUN Invoke-WebRequest "https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/$env:REMOTING_VERSION/remoting-$env:REMOTING_VERSION.jar" -OutFile $env:SLAVE_FILENAME -UseBasicParsing; \
Invoke-WebRequest "https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/$env:REMOTING_VERSION/remoting-$env:REMOTING_VERSION.jar.sha1" -OutFile $env:SLAVE_HASH_FILENAME -UseBasicParsing; \
if ((Get-FileHash $env:SLAVE_FILENAME -Algorithm SHA1).Hash -ne $(Get-Content $env:SLAVE_HASH_FILENAME)) {exit 1};
# escape=`
# Use the latest Windows Server Core image with .NET Framework 4.7.1.
FROM microsoft/dotnet-framework:4.7.1
# Restore the default Windows shell for correct batch processing below.
SHELL ["cmd", "/S", "/C"]
# Download the Build Tools bootstrapper.
ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
# Install Build Tools excluding workloads and components with known issues.
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
--installPath C:\BuildTools `
--all `
--remove Microsoft.VisualStudio.Component.Windows10SDK.10240 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.10586 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
--remove Microsoft.VisualStudio.Component.Windows81SDK `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
# escape=\
# do more stuff
我收到此错误:
Error response from daemon: Dockerfile parse error line 33: unknown instruction: --INSTALLPATH
最佳答案
不支持。解析器指令(如用于更改转义字符的指令)仅在Dockerfile的顶部有效。您不能在第一条非解析器指令行之后更改解析器配置。其中包括FROM
行,任何注释,甚至是空行。此外,每个指令只能设置一次。有关更多详细信息,请参见解析器指令的文档:https://docs.docker.com/engine/reference/builder/#parser-directives
关于windows - 在dockerfile中多次切换转义字符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51549297/