2

I have a docker image that ends with the following CMD:

CMD ["powershell", "c:\install\settings\install.ps1"]

or

CMD powershell c:\install\settings\install.ps1

It did not execute (or perhaps the volume is not mounted yet).

Settings are placed in a mounted volume, and it is started with:

docker run -d -p 80:80 --name openid --rm -v D:\settings\:c:\install\settings mydocker

If I run the command after starting the docker image:

docker exec openid powershell c:\install\settings\install.ps1

It runs fine.

Is there a way of doing this?

Or is there a better way of deploying an IIS website with webdeploy and custom SetParameters.xml?

ipinak
  • 5,739
  • 3
  • 23
  • 41
  • Have you tried to use ENTRYPOINT instead of CMD in your docker file or RUN as you try to install something? Have a look at http://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/ to see the fine differences (if needed) – hecko84 Mar 16 '17 at 13:03
  • I used DSC for prepping containers and IIS inside them. Relying on debugging DOCKERFILE execution is nightmare. DSC provides repeatable and more importangly debuggable way to deal with your application deployments. Details are here. https://github.com/artisticcheese/artisticcheesecontainer/wiki – Gregory Suvalian Mar 16 '17 at 13:58

3 Answers3

1

Try

# set up the shell
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
CMD ["powershell", "c:\\\install\\\settings\\\install.ps1"]

In Windows, the backslash is the separator in file paths, so we have to escape it in Dockerfiles, otherwise it will be interpreted as a line continuation. File paths then have double backslashes \, and the single backslash is used for line continuation

from: https://blog.sixeyed.com/windows-dockerfiles-and-the-backtick-backslash-backlash/

ptrk
  • 1,800
  • 1
  • 15
  • 24
0

try this, might be a problem with the slash.

CMD ["powershell", "c:/install/settings/install.ps1"]

ProgrammerBoy
  • 876
  • 6
  • 19
  • Do you have run multiple commands in your Dockerfile? Can you paste the content of your dockerfile(if not confidential)? – ProgrammerBoy Mar 20 '17 at 07:27
  • `# Get windows` `FROM microsoft/aspnet` `# Install web deploy` `COPY D:/WebDeploy_amd64_en-US.msi /install/WebDeploy_amd64_en-US.msi` `WORKDIR /install` `RUN powershell start-Process msiexec.exe -ArgumentList '/i c:\install\WebDeploy_amd64_en-US.msi /qn' -Wait` `COPY D:/webdeploy/* /install/` `CMD ["powershell", "c:\install\settings\install.ps1"]` – Mikael Ohlsson Mar 20 '17 at 15:21
0

You can pass PS script to docker command as this:

CMD ["powershell .\\myscript.ps1"]
ishara
  • 353
  • 1
  • 10