title: How to start docker container as server
body: <p>I would like to run a docker container that hosts a simple web application, however I do not understand how to design/run the image as a server. For example:</p>
  
  <pre><code>docker run -d -p 80:80 ubuntu:14.04 /bin/bash
  </code></pre>
  
  <p>This will start and immediately shutdown the container. Instead we can start it interactively:</p>
  
  <pre><code>docker run -i -p 80:80 ubuntu:14.04 /bin/bash
  </code></pre>
  
  <p>This works, but now I have to keep open the interactive shell for every container that is running? I would rather just start it and have it running in the background. A hack would be using a command that never returns:</p>
  
  <pre><code>docker run -d -p 80:80 {image} tail -F /var/log/kern.log
  </code></pre>
  
  <p>But now I cannot connect to the shell anymore, to inspect what is going on if the application is acting up. </p>
  
  <p>Is there a way to start the container in the background (as we would do for a vm), in a way that allows for attaching/detaching a shell from the host? Or am I completely missing the point?</p>