title: Apache Tomcat 8 not starting within a docker container
body: <p>I am experimenting with Docker and am very new to it. I am struck at a point for a long time and am not getting a way through and hence came up with this question here...</p>
  
  <p>Problem Statement:
  I am trying to create an image from a docker file containing Apache and lynx installation. Once done I am trying to access tomcat on 8080 of the container which is in turn forwarded to the 8082 of the host. But when running the image I never get tomcat started in the container.</p>
  
  <p>The Docker file</p>
  
  <pre><code>FROM ubuntu:16.10
  #Install Lynx
  Run apt-get update
  Run apt-get install -y lynx
  
  #Install Curl
  Run apt-get install -y curl
  
  #Install tools: jdk
  Run apt-get update
  Run apt-get install -y openjdk-8-jdk wget
  
  #Install apache tomcat
  Run groupadd tomcat
  Run useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
  Run cd /tmp
  Run curl -O http://apache.mirrors.ionfish.org/tomcat/tomcat-    8/v8.5.12/bin/apache-tomcat-8.5.12.tar.gz
  Run mkdir /opt/tomcat
  Run tar xzvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
  Run cd /opt/tomcat
  Run chgrp -R tomcat /opt/tomcat
  Run chmod -R g+r /opt/tomcat/conf
  Run chmod g+x /opt/tomcat/conf
  Run chown -R tomcat /opt/tomcat/webapps /opt/tomcat/work /opt/tomcat/temp opt/tomcat/logs
  
  Run cd /opt/tomcat/bin
  
  Expose 8080
  CMD /opt/tomcat/bin/catalina.sh run &amp;&amp; tail -f /opt/tomcat/logs/catalina.out
  </code></pre>
  
  <p>When the image is built I tried running the container by the two below methods</p>
  
  <ol>
  <li><p>docker run -d -p 8082:8080 imageid tail -f /dev/null
  While using the above, container is running but tomcat is not started inside the container and hence not accessible from localhost:8082. Also I do not see anything if I perform docker logs longcontainerid</p></li>
  <li><p>docker run -d -p 8082:8080 imageid /path/to/catalina.sh start tail -f /dev/null
  I see tomcat started when I do docker logs longconatainrid 
  While using the above the container is started and stopped immediately and is not running as I can see from docker ps and hence again not accessible from localhost:8082.</p></li>
  </ol>
  
  <p>Can anyone please tell me where I am going wrong?</p>
  
  <p>P.s. I searched a lot on the internet but could not get the thing right. Might be there is some concept that i am not getting clearly.</p>