Why does Windows Docker container not wait for exe to finish installing?

Viewed 232

I'm writing a Dockerfile to install an exe on Windows Server 2019 and then run the installed program after.

In the Dockerfile, I call ENTRYPOINT ["test.exe", "-f", "params.txt"] followed by WORKDIR "C:\Program Files\TestInstall\bin", but the WORKDIR fails to execute because the bin folder hasn't been created yet. I have confirmed this by running a dir in between the commands to check what's in the TestInstall directory, and each time, the bin folder hasn't been created yet. However, if I open a shell session after the container exits, the bin folder will be there.

Is there a way to make it wait for the exe to finish installing before running the WORKDIR, or is it dependent on how the exe performs the install?

1 Answers

The ENTRYPOINT instruction is used to specify a command that will be executed when the container starts. This means that the bin directory will not exist when you use workdir, since ENTRYPOINT ["test.exe", "-f", "params.txt"] was not executed yet.

You can see it as if the ENTRYPOINT instruction is the last line that will run in your script (that's probably the reason of why it's usually placed in the end of the Dockerfile.)

A RUN instruction can be used to do what you want.

Related