I have a basic web api (owin self host) app and it runs well in my local docker toolbox (windows).
But when i started it with docker cloud it starts but after 5 or 6 seconds it stops. i dont know what to do. I'm using mono:latest image and my cloud hosting env. is digitalocean.
here is codes
Program.cs:
string address = "http://+:5000";
using (WebApp.Start<Startup>(address))
{
Console.WriteLine("web api listening on port 5000");
Console.Read();
}
just this.
Startup.cs
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional });
app.UseWebApi(config);
Dockerfile :
from mono:latest
run mkdir app
copy ./GAC/bin/Debug /app
workdir /app
expose 5000
entrypoint ["mono"]
cmd ["GAC.exe"] // gac is the console app name.
thats it. I run my container by typing docker run -it -p 80:5000 myContainer
.
And it runs with no stopping issue. i builded my container in windows, so maybe there is some unix based issue that i'm facing.
What do you think? Is there any missing point ?
I found an answer. I dont know why, but the problem is code doesn't wait at all.
The above code is working.
string address = "http://+:5000";
using (WebApp.Start<Startup>(address))
{
Console.WriteLine("web api listening on port 5000");
while(true){}
}