I have a console application written in C# using servicestack that has the following form:
static void Main(string args)
//Some service setup code here
This code works fine when run on windows as a console. The implementation is almost exactly https://github.com/ServiceStack/ServiceStack/wiki/Self-hosting
as this is a test project
I then compile this project using mono on linux and build into a docker file.
I have no problems running up a container based on this image if it is interactive
docker run -it --name bob -p 1337:1337 <myservice>
The container runs in the foreground
However, if I omit the -it switch, the container exits straight away - I assume because there is no STDIN stream, so the Console.ReadKey() doesn't work.
I am trying to get the service hosted in a swarm, so there is no notion of detached. I can spin up a loop within my main method to keep the console service alive, but this seems hacky to me...
Is there a good way of keeping my service alive in the situation where I want to run my container detatched (docker run -d...)