Question:
I’m having a hard time installing an msi via Dockerfile. My Dockerfile:
1 2 3 4 5 6 7 8 |
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:
1 2 |
docker build -t myTools . |
I get the following error:
1 2 3 4 |
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
Answer:
Possibly it’s a PowerShell parsing problem.
Try these 2 lines instead of your last line:
1 2 3 4 |
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:
1 2 |
SHELL ["cmd", "/C"] |