Docker - Windows contaier exits after script

1.4k views Asked by At

I have made a few containers (which run in the Unix environment where the entrypoint is a script file. These script files usually manage some configuration and then carries on executing the CMD by using the exec "$@". While creating/testing such an image I usually return to the command prompt so I manually can assert the configurations. This works fine. However, today I was making a similar image but based on the windows container (microsoft/nanoserver) and here I ran into a few problems.

1) I made a powershell script to do the configuration but in powershell I can't use the exec "$@" to relay the execution to the CMD. What is the equivalent in a windows container?

2) If I create an image based on microsoft/nanoserver and just copy in some files you will stay in interactive mode (if you run the container with -it params of course). But as soon as I point the ENTRYPOINT to a powershell script, the container will terminate immediately after running the script, even though I append a cmd to the run command.

So basically my question is: How do I get it to enter the command prompt after executing a script? (with windows container).

1

There are 1 answers

0
JulioCT On

this question is similar to How to keep WIndows Container running?

if you add at the end of your dockerfile

ping -t localhost

it should leave it running (...unless there is some other errors in the file, of course)