I am trying to build a Windows Container based Micro-Service on Server 2016 CTP5 using .net 4.5.
In the non-container world, I am using a console app deployed as a Windows Service that subscribes to a queue and does its work.
In a container, I can just run the console app and it seems to run just fine. Is there a need to install it as a Windows Service?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With