创建 windows docker 容器时出错
Getting error while creating windows docker container
当我尝试创建 windows docker 容器时,在设置路径时出现错误
我尝试了不同的方法,但所有尝试都失败了,
请提出 docker 文件的问题。
我确定设置路径有问题
如果我不添加系统路径,它会覆盖 java、jboss 路径
如何避免这个问题
PS C:\Users\rajen\Desktop\rajendar\Jboss> docker build -t oraclejdk:jboss .
Sending build context to Docker daemon 866.7MB
Step 1/11 : FROM mcr.microsoft.com/windows/servercore:ltsc2016
---> c569a2ee6f10
Step 2/11 : SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
---> Using cache
---> 8e2560727f24
Step 3/11 : COPY jre1.8.0_45.zip c:\jre1.8.0_45.zip
---> Using cache
---> 001334e133e0
Step 4/11 : COPY jboss-eap-7.0.zip c:\jboss-eap-7.0.zip
---> Using cache
---> 1077fae7b3dd
Step 5/11 : RUN powershell Expand-Archive -Force c:\jre1.8.0_45.zip c:
---> Using cache
---> caa85dc3383a
Step 6/11 : RUN powershell Expand-Archive -Force c:\jboss-eap-7.0.zip c:
---> Using cache
---> 3901a7148b86
Step 7/11 : ENV JAVA_HOME "c:\jre1.8.0_45"
---> Using cache
---> 7a3b6cd69148
Step 8/11 : ENV JBOSS_HOME "c:\jboss-eap-7.0"
---> Using cache
---> b7c237b97158
Step 9/11 : RUN setx /M PATH "c:\jre1.8.0_45\bin;%PATH%"
---> Running in 285463042b56
SUCCESS: Specified value was saved.
%PATH% : The term '%PATH%' 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:108
+ ... eference = 'SilentlyContinue'; setx /M PATH c:\jre1.8.0_45\bin;%PATH%
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (%PATH%:String) [], ParentContai
nsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException
FROM mcr.microsoft.com/windows/servercore:ltsc2016
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY jre1.8.0_45.zip c:\jre1.8.0_45.zip
COPY jboss-eap-7.0.zip c:\jboss-eap-7.0.zip
RUN powershell Expand-Archive -Force c:\jre1.8.0_45.zip c:
RUN powershell Expand-Archive -Force c:\jboss-eap-7.0.zip c:
ENV JAVA_HOME "c:\jre1.8.0_45"
ENV JBOSS_HOME "c:\jboss-eap-7.0"
#ENV path %path%";C:\jre1.8.0_45\bin;C:\jboss-eap-7.0\bin"
#RUN setx PATH "C:\jre1.8.0_45\bin;C:\jboss-eap-7.0\bin;%PATH%"
RUN setx /M PATH "c:\jre1.8.0_45\bin;%PATH%"
#CMD java -version
EXPOSE 8080/tcp
EXPOSE 9990/tcp
#CMD standalone.bat
我不构建 Windows Docker 容器,只构建 Linux 容器,所以我不知道你是否可以这样做。
但是,在使用该图像时,您将始终拥有相同的路径,因此您不需要使用 %PATH%。
您可以只生成 docker 图像,查看默认路径是什么,然后将其硬编码到您的 Docker 文件中,前面加上 c:\jre1.8.0_45。
干杯。
所以它不起作用的原因是因为您 set your shell form 对 PowerShell 和 PowerShell 的环境变量调用看起来与 CMD 的不同。
FROM mcr.microsoft.com/windows/servercore:ltsc2016
# This is where you're setting the form
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY jre1.8.0_45.zip c:\jre1.8.0_45.zip
COPY jboss-eap-7.0.zip c:\jboss-eap-7.0.zip
# Because you're already in powershell, you can simplify these
#RUN powershell Expand-Archive -Force c:\jre1.8.0_45.zip c:
#RUN powershell Expand-Archive -Force c:\jboss-eap-7.0.zip c:
RUN Expand-Archive -Force c:\jre1.8.0_45.zip c:
RUN Expand-Archive -Force c:\jboss-eap-7.0.zip c:
ENV JAVA_HOME "c:\jre1.8.0_45"
ENV JBOSS_HOME "c:\jboss-eap-7.0"
#ENV path %path%";C:\jre1.8.0_45\bin;C:\jboss-eap-7.0\bin"
#RUN setx PATH "C:\jre1.8.0_45\bin;C:\jboss-eap-7.0\bin;%PATH%"
# In PowerShell, instead of %PATH% you would use $env:Path
# RUN setx /M PATH "c:\jre1.8.0_45\bin;%PATH%"
RUN setx /M PATH "c:\jre1.8.0_45\bin;$env:Path"
当我尝试创建 windows docker 容器时,在设置路径时出现错误 我尝试了不同的方法,但所有尝试都失败了, 请提出 docker 文件的问题。 我确定设置路径有问题 如果我不添加系统路径,它会覆盖 java、jboss 路径 如何避免这个问题
PS C:\Users\rajen\Desktop\rajendar\Jboss> docker build -t oraclejdk:jboss .
Sending build context to Docker daemon 866.7MB
Step 1/11 : FROM mcr.microsoft.com/windows/servercore:ltsc2016
---> c569a2ee6f10
Step 2/11 : SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
---> Using cache
---> 8e2560727f24
Step 3/11 : COPY jre1.8.0_45.zip c:\jre1.8.0_45.zip
---> Using cache
---> 001334e133e0
Step 4/11 : COPY jboss-eap-7.0.zip c:\jboss-eap-7.0.zip
---> Using cache
---> 1077fae7b3dd
Step 5/11 : RUN powershell Expand-Archive -Force c:\jre1.8.0_45.zip c:
---> Using cache
---> caa85dc3383a
Step 6/11 : RUN powershell Expand-Archive -Force c:\jboss-eap-7.0.zip c:
---> Using cache
---> 3901a7148b86
Step 7/11 : ENV JAVA_HOME "c:\jre1.8.0_45"
---> Using cache
---> 7a3b6cd69148
Step 8/11 : ENV JBOSS_HOME "c:\jboss-eap-7.0"
---> Using cache
---> b7c237b97158
Step 9/11 : RUN setx /M PATH "c:\jre1.8.0_45\bin;%PATH%"
---> Running in 285463042b56
SUCCESS: Specified value was saved.
%PATH% : The term '%PATH%' 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:108
+ ... eference = 'SilentlyContinue'; setx /M PATH c:\jre1.8.0_45\bin;%PATH%
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (%PATH%:String) [], ParentContai
nsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException
FROM mcr.microsoft.com/windows/servercore:ltsc2016
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY jre1.8.0_45.zip c:\jre1.8.0_45.zip
COPY jboss-eap-7.0.zip c:\jboss-eap-7.0.zip
RUN powershell Expand-Archive -Force c:\jre1.8.0_45.zip c:
RUN powershell Expand-Archive -Force c:\jboss-eap-7.0.zip c:
ENV JAVA_HOME "c:\jre1.8.0_45"
ENV JBOSS_HOME "c:\jboss-eap-7.0"
#ENV path %path%";C:\jre1.8.0_45\bin;C:\jboss-eap-7.0\bin"
#RUN setx PATH "C:\jre1.8.0_45\bin;C:\jboss-eap-7.0\bin;%PATH%"
RUN setx /M PATH "c:\jre1.8.0_45\bin;%PATH%"
#CMD java -version
EXPOSE 8080/tcp
EXPOSE 9990/tcp
#CMD standalone.bat
我不构建 Windows Docker 容器,只构建 Linux 容器,所以我不知道你是否可以这样做。 但是,在使用该图像时,您将始终拥有相同的路径,因此您不需要使用 %PATH%。 您可以只生成 docker 图像,查看默认路径是什么,然后将其硬编码到您的 Docker 文件中,前面加上 c:\jre1.8.0_45。
干杯。
所以它不起作用的原因是因为您 set your shell form 对 PowerShell 和 PowerShell 的环境变量调用看起来与 CMD 的不同。
FROM mcr.microsoft.com/windows/servercore:ltsc2016
# This is where you're setting the form
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY jre1.8.0_45.zip c:\jre1.8.0_45.zip
COPY jboss-eap-7.0.zip c:\jboss-eap-7.0.zip
# Because you're already in powershell, you can simplify these
#RUN powershell Expand-Archive -Force c:\jre1.8.0_45.zip c:
#RUN powershell Expand-Archive -Force c:\jboss-eap-7.0.zip c:
RUN Expand-Archive -Force c:\jre1.8.0_45.zip c:
RUN Expand-Archive -Force c:\jboss-eap-7.0.zip c:
ENV JAVA_HOME "c:\jre1.8.0_45"
ENV JBOSS_HOME "c:\jboss-eap-7.0"
#ENV path %path%";C:\jre1.8.0_45\bin;C:\jboss-eap-7.0\bin"
#RUN setx PATH "C:\jre1.8.0_45\bin;C:\jboss-eap-7.0\bin;%PATH%"
# In PowerShell, instead of %PATH% you would use $env:Path
# RUN setx /M PATH "c:\jre1.8.0_45\bin;%PATH%"
RUN setx /M PATH "c:\jre1.8.0_45\bin;$env:Path"