使用 Docker 在 Nano Server 中进行 Powershell 静默安装

Powershell Silent Install in Nano Server with Docker

我的 docker 文件获取一个 Nano Server 容器,它会自动添加 Java。

# Get nano server
FROM microsoft/nanoserver

# Download file and set in docker container
ADD http://javadl.oracle.com/webapps/download/AutoDL?BundleId=225355_090f390dda5b47b9b721c7dfaa008135 \ 
    'C:\java\jre-8u151-windows-x64.exe'

# Silent install and delete install file
RUN powershell Start-Process -filepath C:\java\jre-8u151-windows-x64.exe -ArgumentList '/s,INSTALLDIR=c:\Java\jre1.8.0_151' -Passthru -Wait; \
    Remove-Item C:\java\jre-8u151-windows-x64.exe -Force

CMD powershell

该过程运行正常,但在 Nano Server 中它不会安装任何东西而不会显示任何错误。但是,对于核心服务器,它会安装它。

静默安装的结果是:

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
              3      476       1464               596   1 jre-8u151-windows-x64

但是,当我检查它是否使用 dir 命令安装时,我看到以下结果:

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       12/21/2017  11:04 AM                Program Files
d-----        7/16/2016   2:09 PM                Program Files (x86)
d-r---        11/3/2017   8:44 PM                Users
d-----       12/21/2017  11:05 AM                Windows
-a----        7/24/2017   6:05 PM       65365056 jre-8u151-windows-x64.exe
-a----       11/20/2016  12:32 PM           1894 License.txt

我怎样才能让这个过程正常工作或者我可以使用什么替代方法?

Windows nano 服务器不支持基于 MSI 的安装。它支持 WSA。请参考:

https://blogs.technet.microsoft.com/nanoserver/2015/11/18/installing-windows-server-apps-on-nano-server/