Leave a Reply

8 comments

  1. this is really cool!!
    I was trying to deploy a Java Jersey webapplication with Docker
    https://github.com/hareendran/Jersey2.0Docker/blob/master/Dockerfile

    But the docker instance is not live it shows as it has exited, not really sure why.
    would you have any insights on this?

    harry Reply

    • The example I provided was made with an older (pre Docker 1.0) version. I’ve encountered some issues when using those ‘older’ Dockerfiles with a new (post Docker 1.0) Docker application installed. Docker was not backwards compatible before version 1.0. My guess is that the command at the end is not compatible anymore. If the command does not keep running, than the container will exit automatically. You could have a look at the logging in the container by using ‘docker logs -f [containerid]’.

      Unfortunately I don’t use those Dockerfiles anymore so I don’t know the exact issue at the moment. Can you try the Dockerfile content below? I tried it quickly and it’s working on my machine :).
      FROM ubuntu:14.04
      RUN apt-get update

      RUN apt-get install -y openjdk-7-jre-headless wget
      RUN wget -O /tmp/tomcat8.tar.gz http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.9/bin/apache-tomcat-8.0.9.tar.gz
      RUN (cd /opt && tar zxf /tmp/tomcat8.tar.gz)
      RUN (mv /opt/apache-tomcat* /opt/tomcat)
      ENV JAVA_HOME /usr/lib/jvm/java-1.7.0-openjdk-amd64

      EXPOSE 8080
      CMD [“/opt/tomcat/bin/catalina.sh”, “run”]

      Johan Janssen Reply

  2. When i start the container using this command i am able to start but i am unable to open the link http://localhost:2000/slashdot/

    kingslee@canberra:~$ sudo docker run -p 2000:2000 -d jgilbert/tomcat7
    ea81be4f72c2201c68f3977d628e1a6e174cff846bbb479716d3ba743622a7bf

    kingslee Reply

    • Can you see if the container is running or stopped? You can use the sudo docker ps -a command to view all containers. It is also possible to look at the logging for instance by using sudo docker logs [containerid].

      Johan Janssen Reply

      • i have build the container using: ‘docker build –t jgilbert/tomcat7.’. Now started the container using ‘docker run -p 2000:2000 -d jgilbert/tomcat7’. but then also iam unable to open the localhost 2000

        kingslee Reply

        • Did you try executing the commands I mentioned? That will hopefully give more information about the problems. Without more information I unfortunately do not know what’s the issue or the solution.

          Johan Janssen Reply

  3. ya i tried your commands.. The steps i followed are …

    1. I created a docker file and the code in the file is
    FROM ubuntu:saucy
    # Update Ubuntu
    RUN apt-get update && apt-get -y upgrade
    # Add oracle java 7 repository
    RUN apt-get -y install software-properties-common
    RUN add-apt-repository ppa:webupd8team/java
    RUN apt-get -y update
    # Accept the Oracle Java license
    RUN echo “oracle-java7-installer shared/accepted-oracle-license-v1-1 boolean true” | debconf-set-selections
    # Install Oracle Java
    RUN apt-get -y install oracle-java7-installer
    # Install tomcat
    RUN apt-get -y install tomcat7
    RUN echo “JAVA_HOME=/usr/lib/jvm/java-7-oracle” >> /etc/default/tomcat7
    EXPOSE 2000
    # Download Slashdot homepage
    RUN mkdir /var/lib/tomcat7/webapps/slashdot
    RUN wget http://www.slashdot.org -P /var/lib/tomcat7/webapps/slashdot
    # Start Tomcat, after starting Tomcat the container will stop. So use a ‘trick’ to keep it running.
    CMD service tomcat7 start && tail -f /var/lib/tomcat7/logs/catalina.out

    2. And after that i build the code using the command docker build –t tomcat7
    3. And i run the code docker run -p 2000:2000 -d tomcat7 till then its working fine
    4. After that while starting the http://localhost:2000/slashdot/ i am unable to start the local host ..

    kingslee Reply

    • Can you also post the output of the commands I mentioned?

      Johan Janssen Reply