Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DockerFile call install msi

I'm having a hard time installing an msi via Dockerfile. My 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}

When running docker build via:

docker build -t myTools .

I get the following error:

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.

If I build the container without the RUN step, and attach myself via -it to the running container and paste the command powershell -version 5.0 -command { Start-process -Filepath "C:\temp\msis\mySetup.msi" -ArgumentList "/qn" -PassThru | Wait-Process} the MSI gets installed correctly.

Has anyone an idea this failure happens?

Thx

like image 883
Moerwald Avatar asked Mar 29 '18 10:03

Moerwald


1 Answers

Possibly it's a PowerShell parsing problem.

Try these 2 lines instead of your last line:

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

RUN Start-Process 'C:\\temp\\msis\\mySetup.msi' '/qn' -PassThru | Wait-Process;

After that you can revert to cmd.exe if you wish:

SHELL ["cmd", "/C"]
like image 64
v.karbovnichy Avatar answered Oct 28 '22 03:10

v.karbovnichy