title: Why httpd container exits immediately without any error in Docker
body: <p>I am new to Docker. My Dockerfile (got from a tutorial) is:</p>
  
  <pre><code>FROM ubuntu
  
  ENV DEBIAN_FRONTEND noninteractive
  
  RUN apt-get update \
  &amp;&amp; apt-get install -y --no-install-recommends apache2 \
                          libapache2-mod-jk
  VOLUME ["/var/log/apache2"]
  RUN echo 'ServerName localhost' &gt;&gt; /etc/apache2/apache2.conf
  EXPOSE 80 443
  
  ENTRYPOINT ["apache2ctl", "-D", "FOREGROUND"]
  </code></pre>
  
  <p>I gave <code>docker build -t mg:httpd apache\</code>. No errors.</p>
  
  <pre><code>λ docker images
  REPOSITORY          TAG                 IMAGE ID            CREATED                SIZE
  mg                  httpd               262d7a4f85fc        About an hour ago      248MB
  </code></pre>
  
  <p><code>docker run -it mg:httpd</code></p>
  
  <p>No errors, but the cursor returns to command prompt immediately. Getting <code>Unable to connect</code> on taking <code>http://localhost/</code> in browser. </p>
  
  <pre><code>λ docker ps -a
  CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                         PORTS                
  600231bbd461        mg:httpd            "apache2ctl -D FOR..."   2 minutes ago       Exited (0) 2 minutes ago             
  </code></pre>
  
  <p>docker logs is empty </p>
  
  <pre><code>λ docker events
  2017-09-08T15:26:10.726720800+05:30 container create 5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157 (image=mg:httpd, name=zealous_ritchie)
  2017-09-08T15:26:10.740310700+05:30 container attach 5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157 (image=mg:httpd, name=zealous_ritchie)
  2017-09-08T15:26:11.035777100+05:30 network connect 2b8829b336575a2aa2210f55105d793e8f1b196d51845d38d3dc8ff322af6143 (container=5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157, name=bridge, type=bridge)
  2017-09-08T15:26:11.090873500+05:30 volume mount e8421cbd867fca04f0dd3ee6da815c59cad5fc32c5a427710d144213b43caa26 (container=5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157, destination=/var/log/apache2, driver=local, propagation=, read/write=true)
  2017-09-08T15:26:11.548736900+05:30 container start 5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157 (image=mg:httpd, name=zealous_ritchie)
  2017-09-08T15:26:11.573272300+05:30 container resize 5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157 (height=41, image=mg:httpd, name=zealous_ritchie, width=168)
  2017-09-08T15:26:12.733164900+05:30 container die 5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157 (exitCode=0, image=mg:httpd, name=zealous_ritchie)
  2017-09-08T15:26:13.227455500+05:30 network disconnect 2b8829b336575a2aa2210f55105d793e8f1b196d51845d38d3dc8ff322af6143 (container=5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157, name=bridge, type=bridge)
  2017-09-08T15:26:13.306885700+05:30 volume unmount e8421cbd867fca04f0dd3ee6da815c59cad5fc32c5a427710d144213b43caa26 (container=5325b79abe1988312952629165551c169a8bdc3fbe6e473cf0177859db7c0157, driver=local)
  </code></pre>
  
  <p>what could be the reason?   How can I look into the apache log\conf files when the container is not started?            </p>