DockerFile调用安装MSI

Moe*_*ald 3 powershell docker

我很难通过Dockerfile安装MSI。我的Dockerfile:

FROM microsoft/windowsservercore:latest

RUN mkdir C:\temp 
RUN mkdir C:\temp\msis

COPY . "C:/temp/msis"
RUN powershell -version 5.0 -command { Start-process -Filepath "C:\temp\msis\mySetup.msi" -ArgumentList  "/qn" -PassThru | Wait-Process}
Run Code Online (Sandbox Code Playgroud)

当运行docker build通过:

docker build -t myTools .
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Step 7/7 : RUN powershell -version 5.0 -command { Start-process -Filepath "C:\temp\msis\mySetup.msi" -ArgumentList  "/qn" -PassThru | Wait-Process}
---> Running in d6f9f65d96a9
'Wait-Process}' is not recognized as an internal or external command,operable program or batch file.
Run Code Online (Sandbox Code Playgroud)

如果我在不运行RUN步骤的情况下构建了容器,则将我自己附加-it到正在运行的容器中,并粘贴命令powershell -version 5.0 -command { Start-process -Filepath "C:\temp\msis\mySetup.msi" -ArgumentList "/qn" -PassThru | Wait-Process}以正确安装MSI。

有谁知道这种失败会发生吗?

谢谢

v.k*_*chy 7

可能是PowerShell分析问题。

尝试以下两行,而不是最后一行:

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

RUN Start-Process 'C:\\temp\\msis\\mySetup.msi' '/qn' -PassThru | Wait-Process;
Run Code Online (Sandbox Code Playgroud)

之后,您可以根据需要还原到cmd.exe:

SHELL ["cmd", "/C"]
Run Code Online (Sandbox Code Playgroud)