Skip to main content


Showing posts from June, 2017

Executing .ps1 files in a DockerFile

This week I was trying to containerize an existing java application. Part of "installing" the application  on the container required executing an PowerShell script in the container during the Image build. Based on the documentation here I thought i could add the following command to my dockerfile and it would work:

RUN install.ps1

However, when I went to build the image, it just hung on that step. I tried several other variations of the run command including:

RUN ["Powershell", ".\install.ps1"]
which resulted in the following error: '["Powershell"' is not recognized as an internal or external command,operable program or batch file.

RUN ["Powershell.exe", ".\install.ps1"] which returned the same error as above.

I was about to give up and move the PowerShell commands from the .ps1 file directly into the dockerfile itself as described here, but I had an "A HA!" moment and decided to give a simpler approach a tr…