docker container exits immediately even with Conso

2019-01-26 05:23发布

I am trying to run a .net core 1.0.0 console application inside a docker container.
When I run dotnet run command from inside the Demo folder on my machine, it works fine; But when run using docker run -d --name demo Demo, the container exits immediately.

I tried docker logs demo to check the logs and it just shows the text from the Console.WriteLine:

Demo app running...

and nothing else.

I have uploaded the project at https://github.com/learningdockerandnetcore/Demo

The project contains Programs.cs, Dockerfile used to create Demo image, and project.json file.

7条回答
We Are One
2楼-- · 2019-01-26 05:58

You should either run your container in the Interactive mode (with -i option). but please note that the background processes will be closed immediately when you run the container so make sure your script is run in the foreground or it simply won't work.

查看更多
登录 后发表回答