Docker Community Forums

Share and learn in the Docker community.

Multiple Tomcat Containers

(Akd1234) #1

I am pretty new to Docker. Can we have mutiple tomcat images deployed. Multiple war to be pushed to each tomcats webapps folder? How do we do that. by default it will /user/local/tomcat/webapps . Am i correct? Please help!!!

(Nathan Le Claire) #2


use a common base image and copy over only the bits that change per-app. something like

FROM user/tomcatbase

COPY . /src
RUN /src/
RUN cp /src/my.war /usr/local/tomcat/webapps

(don’t really know Java/Tomcat, but the general idea is the same – if you really want to get fancy build the war in one container then docker cp or use volumes to get it into another one with only runtime deps)

(Catherine Cai) #3

The problem is that building the war involves pulling dependencies. The workaround to this I’ve used is to just prepackage the war using Maven, setting the path/name to the war using a ENV variable, and then having the Tomcat container copy in the war and launch it.