我有一些问题运行我的Dockerfile…
它是这样的:
FROM mcr.microsoft.com/windows/servercore:ltsc2019
USER ContainerAdministrator
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue';"]
RUN mkdir "C:/apache-ant-1.10.13"
RUN mkdir "C:/Project"
COPY "/CustomJDK/" "C:/jdk/"
COPY "/PROJECT/" "C:/Project/"
COPY "/apache-ant-1.10.13/" "C:/apache-ant-1.10.13/"
ENV ANT_HOME=C:/apache-ant-1.10.13
ENV JAVA_HOME=C:/jdk
ENV PATH=%ANT_HOME%/bin;%PATH%
ENV PATH=%JAVA_HOME%/bin;%PATH%
WORKDIR %PROJECT_HOME%
RUN ["cmd", "/C", "C:/apache-ant-1.10.13/bin/ant -buildfile build.xml"]
COPY ["C:/Project/dist/project.ear", "C:/EAR"]
我在最后一个RUN步骤有一个问题- 'ant'不被识别…
Step ~~/~~: RUN ["cmd", "/C", "ant -buildfile build.xml"]
---> Running in 14cda2b05e87
'ant' is not recognized as an internal or external command,
operable program or batch file.
The command 'cmd /C ant -buildfile build.xml' returned a non-zero code: 1
我实际上已经给了环境变量- ant/bin给PATH,它应该被识别。
怎么了?
尝试更改ENV语句使用反斜杠而不是正斜杠,因为Windows使用反斜杠表示目录路径:
ENV ANT_HOME=C:apache-ant-1.10.13
ENV JAVA_HOME=C:jdk
ENV PATH=%ANT_HOME%bin;%PATH%
ENV PATH=%JAVA_HOME%bin;%PATH%