Console App or Windows Service in Windows Container? Console App or Windows Service in Windows Container? docker docker

Console App or Windows Service in Windows Container?


No, you don't want to install it as a service. When you run an application in a container, Docker monitors the active process in the container. If the active process stops, the container exits. So you should run your app in the foreground, and let Docker put the container in the background (by starting it with docker run -d).

An exception is where the existing platform is already a Windows Service - e.g. the microsoft/iis image. IIS is running in the background in the container, so you need to start another process to keep the container running - which is why you see IIS containers started like this:

docker run -d -p 80:80 microsoft/iis ping -t localhost

The ping command keeps the container running, while the IIS service actually responds to requests. This is not ideal though, Docker is monitoring ping so if the IIS service stops the container keeps running.