Docker tomcat edit expanded war files Docker tomcat edit expanded war files docker docker

Docker tomcat edit expanded war files


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.


How about unzipping your war manually, before starting tomcat?

ADD my.war /tmp/my.war RUN unzip /tmp/my.war -d /usr/local/tomcat/webapps/mywar# Edit config files# Now you can start tomcat...CMD ["catalina.sh", "run"]


Just add a RUN instruction which launches the server in the background, gives it a few seconds then exits i.e.

RUN bash -c "catalina.sh start; sleep 5; catalina.sh stop;"

You will need to give it long enough to expand the war file.