title: Docker ASP.net 5 beta4 kestrel doesn't keep container running
body: <p>I was playing with <a href="https://registry.hub.docker.com/u/microsoft/aspnet/" rel="nofollow">ASP.net 5 beta 4 docker image</a>.
  I am running the container with the entrypoint <code>dnx /app kestrel</code>.
  The Dockerfile is standard from tutorials:</p>
  
  <pre><code>FROM microsoft/aspnet:1.0.0-beta4
  MAINTAINER "xxxx" &lt;xxxx&gt;
  
  #this contains project.json etc
  COPY ./app /app 
  
  WORKDIR /app
  
  RUN ["dnu", "restore"]
  
  EXPOSE 5004
  
  ENTRYPOINT ["dnx", "/app", "kestrel"]
  </code></pre>
  
  <p>The container starts and exits immediately, the logs for the container shows:
  "Started" which indicates that there were no errors starting kestrel.</p>
  
  <p>The docker command I used was <code>docker run -d -p "5004:5004" my_asp_net_5_docker_image:1.0.0</code> </p>
  
  <p>What intrigues me is that if I run the container with a pseudo-tty, by doing</p>
  
  <pre><code>docker run -t -i -p "5004:5004" --entrypoint="/bin/bash" my_asp_net_5_docker_image:1.0.0
  </code></pre>
  
  <p>and then when I am inside the docker container I run the entrypoint command manually <code>dnx /app kestrel</code>, kestrel starts, the output is "Started" and it remains alive, and I can access the HelloWorld website successfully.
  I wonder why this difference of behaviour. Why doesn't <code>dnx /app kestrel</code>
  keep the container alive when I run it in the entrypoint but it does when I run it from inside the container.</p>
  
  <p>UPDATE: 
  I found something interesting <a href="https://github.com/aspnet/Hosting/commit/95b1997c14bb6fb7e2e68dd156f4feee3d139fec" rel="nofollow">here</a>
  This is a change in asp.net git hub that says "Don't require a TTY on Unix." there was a line after "Started" that did a Console.ReadLine(), it could be that this code still be in the asp.net docker image therefore it only works with tty...</p>
  
  <p>UPDATE 2:
  I can get it working by opening stdin (-i): <code>docker run -d -i -p "5004:5004" my_asp_net_5_docker_image:1.0.0</code>
  Which suggests that the Console.ReadLine() could be the issue. This solves the problem for me now, but I don't think we should have to use -i to get the container running.</p>