Docker tomcat edits advanced war files

I am using docker to deploy a tomcat container with a third-party file war.

My Dockerfilelooks something like this:

FROM tomcat:7-jre8

ADD my.war ${CATALINA_HOME}/webapps/my.war 

When I start the container, tomcat extends mine warat runtime, and I can happily access my application in http://my.ip.addr:8080/mywar/.

However, my problem is that I want to edit a couple of configuration files in war. I really do not want to unzip and repack the file waras it seems dirty and difficult to maintain.

I was hoping I could tell tomcat about the extension waras part of my steps RUN, and then use it ADDto input my user files, but I cannot find a way to do this. The war only expands when executed CMD, after which I cannot edit the files after that.

+4
source share
4 answers

I'm not sure exactly how you will achieve this with docker or anything else, since I don't see anyone asking tomcat to just expand the war before it starts. But in accordance with standard practices, it is not recommended to blow up the war and customize the contents. He kills the whole purpose of the war.

, < < TOMCAT_HOME → /conf.

, , Docker, - tomcat conf.

, , , : ( script) , , . -

ADD./target/app-0.1.0.BUILD-SNAPSHOT/var/lib/jetty/webapps/ROOT.

.

ADD login.jsp/var/lib/jetty/webapps/ROOT/Webapps, ..

+3

, 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"]
+1

"", tomcat, . , .

:

RUN Start_tomcat.sh && \
    stop_tomcat.sh && \
    edit_1_config_file.sh && \
    edit_2_config_file.sh

. . Docker , , . , , RUN, .

0

RUN, , , .

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

, .

0

All Articles