Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Powershell script in DockerFile?

I try these below commands in dockerfile but it didnot run the script.so are there any other commands for running the ps script in dockerfile?

ADD Windowss.ps1 .

CMD powershell .\Windowss.ps1;

like image 912
shad Avatar asked Nov 06 '17 07:11

shad


2 Answers

To run a PS1 script file, you can do something like this:

SHELL ["cmd", "/S", "/C"]    
RUN powershell -noexit "& ""C:\Chocolatey\lib\chocolatey.0.10.8\tools\chocolateyInstall.ps1"""

You can also do:

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
WORKDIR C:\
RUN .\install_pfx.ps1
like image 159
Ian Robertson Avatar answered Sep 19 '22 14:09

Ian Robertson


You can use RUN.

You can RUN poweshell commands using

RUN powershell -Command Add-WindowsFeature Web-Server

Refer https://docs.microsoft.com/en-us/dotnet/standard/containerized-lifecycle-architecture/design-develop-containerized-apps/set-up-windows-containers-with-powershell

like image 33
Shinva Avatar answered Sep 21 '22 14:09

Shinva