Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Console App or Windows Service in Windows Container?

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?

like image 973
TalMcMahon Avatar asked Sep 26 '16 14:09

TalMcMahon


1 Answers

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.

like image 162
Elton Stoneman Avatar answered Oct 17 '22 09:10

Elton Stoneman