microsoft/nanoserver docker映像无法启动java.exe,而microsoft/windowsservercore成功启动
我正在尝试从microsoft/nanoserver docker映像无法启动java.exe,而microsoft/windowsservercore成功启动,java,windows,docker,windows-server,nano-server,Java,Windows,Docker,Windows Server,Nano Server,我正在尝试从microsoft/nanoserverimage使用java创建Windows docker映像 系统信息 Dockerfile Dockerfile是本文第4节的一个稍加修改的版本: 塑造形象 运行它 基本映像运行 Windows服务器核心版本 Dockerfile 塑造形象 运行它 问题: 如何检测nanoserver有什么问题? 观察C:\ProgramData\Docker\containers\不会给出任何结果-没有*.log文件。这似乎主要是安装问题。一步一个脚印 St
microsoft/nanoserver
image使用java创建Windows docker映像
系统信息
Dockerfile
Dockerfile是本文第4节的一个稍加修改的版本:
塑造形象
运行它
基本映像运行
Windows服务器核心版本
Dockerfile
塑造形象
运行它
问题:
如何检测nanoserver有什么问题?观察
C:\ProgramData\Docker\containers\
不会给出任何结果-没有*.log文件。这似乎主要是安装问题。一步一个脚印
Step 3/5 : RUN powershell start-process -filepath C:\jre-8u91-windows-x64.exe -passthru -wait -argumentlist "/s,INSTALLDIR=c:\Java\jre1.8.0_91,/L,install64.log"
就退出代码而言,它正在成功运行,但可能是安装程序遇到了一些问题。您应该运行shell并检查安装程序是否正常工作
docker run -it java-nano:jre1.8.0_91 powershell
您也可以尝试重新安装,看看安装程序是否有错误。可能是某些依赖项不存在我将笔记本电脑的当前JRE安装(C:\Program Files\Java\jre1.8.0\u 221)压缩到jre1.8.0\u 221.zip中。然后使用dockerfile:
FROM mcr.microsoft.com/windows/nanoserver:10.0.14393.1066
COPY jre1.8.0_221.zip c:\\jre1.8.0_221.zip
RUN powershell Expand-Archive -Force c:\jre1.8.0_221.zip c:
ENV JAVA_HOME "C:\jre1.8.0_221"
ENV PATH "C:\jre1.8.0_221\bin"
CMD java -version
这对我很有用。做一件事,用powershell运行nano服务器,而不是java
docker运行-It java nano:jre1.8.091PowerShell
,然后检查java是否正确热安装,以及文件是否真的存在。@TarunLalwani非常感谢!我进入了容器,在nano映像中没有Java,但是Java出现在核心映像中。你能不能加上这个作为回答,这样我就可以接受了?
> docker run -it java-nano:jre1.8.0_91
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: container 55868b76113bbb1231e1b59e26bf2301b7d1a80a7cb1617efed862a5d4516401 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file sp
ecified. (0x2) extra info: {"ApplicationName":"","CommandLine":"c:\\Java\\jre1.8.0_91\\bin\\java.exe -version","User":"","WorkingDirectory":"C:\\","Environment":{},"EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":false,"ConsoleSize"
:[48,164]}.
>docker run microsoft/nanoserver
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
FROM microsoft/windowsservercore
RUN powershell -Command iwr 'http://javadl.oracle.com/webapps/download/AutoDL?BundleId=210185' -Outfile 'C:\jre-8u91-windows-x64.exe'
RUN powershell start-process -filepath C:\jre-8u91-windows-x64.exe -passthru -wait -argumentlist "/s,INSTALLDIR=c:\Java\jre1.8.0_91,/L,install64.log"
RUN del C:\jre-8u91-windows-x64.exe
CMD [ "c:\\Java\\jre1.8.0_91\\bin\\java.exe", "-version"]
> docker build -t java-core:jre1.8.0_91 .
Sending build context to Docker daemon 2.048kB
Step 1/5 : FROM microsoft/windowsservercore
---> 2c42a1b4dea8
Step 2/5 : RUN powershell -Command iwr 'http://javadl.oracle.com/webapps/download/AutoDL?BundleId=210185' -Outfile 'C:\jre-8u91-windows-x64.exe'
---> Running in 8eef04cb451e
---> 9f1ad85b2b05
Removing intermediate container 8eef04cb451e
Step 3/5 : RUN powershell start-process -filepath C:\jre-8u91-windows-x64.exe -passthru -wait -argumentlist "/s,INSTALLDIR=c:\Java\jre1.8.0_91,/L,install64.log"
---> Running in ef30759baacf
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
0 1 388 68 0.16 2060 1 jre-8u91-windows-x64
---> f05ce070cd55
Removing intermediate container ef30759baacf
Step 4/5 : RUN del C:\jre-8u91-windows-x64.exe
---> Running in 8dfc09e67472
---> ea9f0c6c9f8a
Removing intermediate container 8dfc09e67472
Step 5/5 : CMD c:\Java\jre1.8.0_91\bin\java.exe -version
---> Running in c0aa37469049
---> c1b7ccca9adc
Removing intermediate container c0aa37469049
Successfully built c1b7ccca9adc
Successfully tagged java-core:jre1.8.0_91
> docker run -it java-core:jre1.8.0_91
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b15, mixed mode)
Step 3/5 : RUN powershell start-process -filepath C:\jre-8u91-windows-x64.exe -passthru -wait -argumentlist "/s,INSTALLDIR=c:\Java\jre1.8.0_91,/L,install64.log"
docker run -it java-nano:jre1.8.0_91 powershell
FROM mcr.microsoft.com/windows/nanoserver:10.0.14393.1066
COPY jre1.8.0_221.zip c:\\jre1.8.0_221.zip
RUN powershell Expand-Archive -Force c:\jre1.8.0_221.zip c:
ENV JAVA_HOME "C:\jre1.8.0_221"
ENV PATH "C:\jre1.8.0_221\bin"
CMD java -version