0

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 ?

afrikaan
  • 425
  • 5
  • 21

2 Answers2

0

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){}
    }
afrikaan
  • 425
  • 5
  • 21
-1

Hi I assume you have an API Controller in the mix too? Also, what are you pushing to docker cloud? I assume it is an image rather than a container? Thanks.

muszeo
  • 2,312
  • 9
  • 13
  • Yes, i have an api controller, and i pushed an image based on dockerfile that i've already mention . – afrikaan Jun 02 '16 at 10:58
  • I can only think that GAC.exe is exiting early for some reason. You could try using the docker logs command to see if anything is being outputted by your app on docker cloud, as without it telling you something this is a bit like looking for a needle in a haystack! If you manage to get some output please post to back - I may be able to help! – muszeo Jun 03 '16 at 07:36