Public | Automated Build

Last pushed: 2 years ago
Short Description
Short description is empty for this repo.
Full Description

Apache Tomcat 8 optimized images

This repository contains Dockerfile of Apache Tomcat 8.

It use a Docker's personal build published to the public Docker Registry.


This docker apache tomcat images supports production and development. A lot of other tomcat docker images exist, but the only support development or not use the newest version or bundle an open jdk. We want build a nicer one. Send us your missing features!


  • use minimal ubuntu and java8 base images (work in progress)
  • inject libs and wars as volumes (data container)
  • deploy the manager app and generate password at start
  • clean up installation and remove examples and unused *.bat, .. files.
  • squash footprint and clean up build artefacts
  • use a nicer access log pattern :-)
  • use a cleanup server.xml without comments
    • use separate executor
    • setup HTTP (8080) and AJP (8009) connectors and expose ports
    • currently not support APR Connectors or configure other then standard NIO
  • reuse existing cool ideas from other nice guys. Many thanks;)

You can deploy your own webapps and tomcat extended library with local volumens or better with a docker data container.

Found the tomcat docker images

Currently the apache tomcat8 images are available as automatic docker hub build and a squash version.



  1. Install Docker.
  2. Download rossbachp/java8: docker pull rossbachp/java8
  3. Download rossbachp/tomcat8: docker pull rossbachp/tomcat8 or rossbachp/apache-tomcat8: docker pull rossbachp/apache-tomcat8 or


docker run -it --rm -P rossbachp/apache-tomcat8
docker run -it --rm -P rossbachp/tomcat8

Run tomcat8 with a sample hello world

mkdir -p hello
cd hello
echo "Hello Docker Tomcat World" >index.jsp
jar -cf ../hello.war .
cd ..
docker run --name=tomcat8 -d -p 8080:8080 -v `pwd`:/webapps rossbachp/tomcat8

Run tomcat8 with a sample hello world at a data container

mkdir -p hello
cd hello
echo "Hello Docker Tomcat World" >index.jsp
jar -cf ../hello.war .
cd ..
vi Dockerfile


FROM busybox
MAINTAINER Peter Rossbach <>

RUN mkdir /webapps
ADD hello.war /webapps/hello.war

VOLUME ["/webapps"]

CMD /bin/sh


docker build -t="rossbachp/hello-app".
docker run -it --name=hello-app rossbach/hello-app ls /webapps
docker run --name=tomcat8 -d -p 8080:8080 --volumes-from hello-app rossbachp/tomcat8

deploy with your system parameters

docker run -it --rm --env CATALINA_OPTS="-Ddb.user=admin -Ddb.password=secret" -v `pwd`/webapps:/webapps -v `pwd`/libs:/libs rossbachp/tomcat8

use your own JVM_ROUTE

docker run -it --rm --env TOMCAT_JVM_ROUTE=tomcat79 -p 7980:8080 -p 7909:8009 -v `pwd`/webapps:/webapps rossbachp/tomcat8

stop tomcat

docker stop --time=10 tomcat8
  • This send SIGTERM and after 10 seconds sends SIGKILL, if tomcat process is not stopped before.

tomcat docker images ENV parameter

Parameter Default Comment
JAVA_MAXMEMORY 256 setup jvm max memory
TOMCAT_MAXTHREADS 250 setup max executor threads
TOMCAT_MINSPARETHREADS 4 setup min spare executor threads
TOMCAT_HTTPTIMEOUT 20000 setup http connector timeout
TOMCAT_JVM_ROUTE tomcat80 support session sticky ness suffix
TOMCAT_JVM_ROUTE tomcat80 support session sticky ness suffix
TOMCAT_PASS random generated admin password
CATALINA_OPTS s. tomcat start parameter
JAVA_OPTS s. spezial java start/stop parameter

get tomcat container IP and ports

$ DOCKER_HOST_IP=$(docker inspect -f '{{.NetworkSettings.IPAddress}}'
$ docker inspect -f '{{ range $key, $value := .NetworkSettings.Ports }}{{ $key }}='"${DOCKER_HOST_IP}:"'{{ (index $value 0).HostPort }} {{ end }}‘ tomcat8 | tr " " "\n"

Run list all deployed apps

$ DOCKER_HOST_IP=$(docker inspect -f '{{.NetworkSettings.IPAddress}}' tomcat8)
$ curl --user "admin:password" http://${DOCKER_HOST_IP}:8080/manager/text/list
OK - Listed applications for virtual host localhost

The admin password can be extract from logs:

$ docker logs tomcat8 | head
=> Creating and admin user with a random password in Tomcat
=> Done!
You can now configure to this Tomcat server using:


Checking *.war in /webapps
Checking tomcat extended libs *.jar in /libs

or set at your password at container starts:

docker run -d --name=tomcat8 --env TOMCAT_PASS=password rossbachp/tomcat8

debug tomcat with nsenter

Install nsenter:

sudo docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter

Tail tomcat app or access logs

sudo docker-enter tomcat8 tail -f /opt/tomcat/logs/catalina-2014-08-27.log
sudo docker-enter tomcat8 tail -f /opt/tomcat/logs/access-2014-08-27.log


sudo docker logs tail tomcat8

Run jstat

sudo docker-enter tomcat8 su tomcat --shell /bin/bash -c 'jstat -gc 1 5000'

More space for research:

  • run jonsole?
    • add jmx port and expose
    • secure
  • load jolokia and monitor via http

manually build, squash and push

sudo bash
cd /tmp
docker build -t="rossbachp/tomcat8" .
ID=$(docker inspect -f '{{ .Id }}' rossbachp/tomcat8)
docker save $ID > tomcat8.tar
sudo docker-squash -verbose -i tomcat8.tar -o tomcat8-squash.tar -t rossbachp/tomcat8:squash
cat tomcat8-squash.tar | docker load
rm tomcat8.tar
rm tomcat8-squash.tar

or simple use the `./ or with cleanup ./ --rmi

Push to docker hub registry

docker login
docker push rossbachp/tomcat8:latest
docker push rossbachp/tomcat8:<DATE TAG>


Option for better logging

  • Use a volume for logging sudo docker run --rm -t -v /var/log/tomcat8:/opt/tomcat/logs rossbachp/tomcat8 and delegate it to logstash-forwarder or rsyslog.
  • Use only stdout/stderr or file output handler
  • Don't let make file rotation, compression and archive control from outside

The current configured logging need a better solutions!

At your application you can use beter directly use syslog but how we configure syslog host?:

<appender name="SYSLOG" class="">
        <suffixPattern>app: %logger{20} %msg</suffixPattern>
  • Use DNS link name at /etc/hosts with new writable docker >= 1.2 feature

Other nice tomcat docker images


  • setup better logging
  • setup JMX and monitoring
  • support APR Connector
  • support SSL
  • setup your own server.xml
  • integrate a check api
  • more samples
    • JDBC sample with fig setup
    • auto scaling apache/mod_jk ectd sample

Have fun with this tomcat images and give feedback!


Docker Pull Command
Source Repository