I am using docker to deploy a tomcat container running a third party war
file.
My Dockerfile
looks something like this
FROM tomcat:7-jre8
ADD my.war ${CATALINA_HOME}/webapps/my.war
When I run the container tomcat expands my war
at runtime and I can happily access my app at http://my.ip.addr:8080/mywar/
.
However my problem is that I want to edit a couple of the config files within the war
. I don't really want to unpack and repack the war
file as that seems messy and hard to maintain.
I was hoping to be able to tell tomcat to expand the war
as part of my RUN
steps and then use ADD
to put in my custom files but I can't seem to find a way of doing this. The war only gets expanded when the CMD
executes and then I can't edit the files after that.
I am not sure exactly how you would achieve it with docker or anything else, as i dont see anyway to ask tomcat to just expand the war before it actually starts. But as per standard practices its not a good idea to explode a war and tweak the contents. It kills the entire purpose of making a war.
Rather you should make changes to the app to read configuration from << TOMCAT_HOME >>/conf.
If you achieve this the only thing you will need to tell Docker is to ADD your configuration file to the containers tomcat conf folder.
Or if it is a must for you to tamper with war file this is what you can do: Explode the war manually (or by script) on your build machine and instead of adding war directly to the docker image, map the folder. Something like this
ADD ./target/app-0.1.0.BUILD-SNAPSHOT /var/lib/jetty/webapps/ROOT.
And then manually add all your files to desired destinations.
ADD login.jsp /var/lib/jetty/webapps/ROOT/Webapps, so on and so forth.