Search code examples
dockerdockerfile

How to launch an exe in Windows docker container without using CMD or ENTRYPOINT?


I have a Windows docker container for running an Azure function app in node.js, so the last line in the Dockerfile is "CMD npm start". However, my app requires that a specific executable be running in the container as well. Right now I have a function in my function app that starts the executable when called, but I need it to start automatically as part of the container starting up. Because this is a function app, there is no single entry point where I can call my start function before anything else, so I need to find a way to start the executable in the Dockerfile itself.

The CMD of a Dockerfile will let me launch an executable OR run "npm start", but not both, so I'm trying to find another way to launch the executable.

When launching the exe in a command console locally the prompt shows up again right away for the next command, so I assumed I could just do this:

RUN ProgramName.exe
CMD npm start

or

CMD ProgramName.exe && npm start

But when I do this, the command hangs indefinitely and I have no idea why.

Does anyone know how I can automatically start the exe running in my container without using the CMD or ENTRYPOINT for it?


Solution

  • You need to get the program to run in the background somehow. If it were a Linux container, I'd know how to. But with Windows, I don't.

    Maybe use the start command? https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/start