Docker Tomcat编辑扩展的War文件 [英] Docker tomcat edit expanded war files

查看:109
本文介绍了Docker Tomcat编辑扩展的War文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用docker部署运行第三方 war 文件的tomcat容器。

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

我的 Dockerfile 看起来像这样

FROM tomcat:7-jre8

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

我运行时容器tomcat在运行时扩展了我的 war ,我可以通过 http://my.ip.addr:8080 / mywar /

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/.

但是我的问题是我想在 war 。我真的不想解压缩并重新打包 war 文件,因为这看起来很杂乱且难以维护。

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.

我希望能够告诉tomcat扩展 war 作为我的 RUN 步骤的一部分,然后使用 ADD 放入我的自定义文件中,但我似乎找不到解决方法。只有执行 CMD 之后,战争才会扩大,然后我再也无法编辑文件。

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.

推荐答案

我不确定您将如何使用docker或其他工具来实现它,因为我仍然看不到要tomcat在战争真正开始之前就扩大战争。但是按照标准惯例,爆发战争并调整内容并不是一个好主意。

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.

相反,您应该更改应用程序以从<<读取配置。 TOMCAT_HOME >> / conf。

Rather you should make changes to the app to read configuration from << TOMCAT_HOME >>/conf.

如果实现了这一点,您唯一需要告诉Docker的就是将配置文件添加到容器tomcat 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.

或者如果您必须篡改war文件,可以执行以下操作:
在构建计算机上手动(或通过脚本)展开战争,然后映射文件夹,而不是直接向docker映像添加战争。
这样的东西

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

添加./target/app-0.1.0.BUILD-SNAPSHOT/var/lib/jetty/webapps/ROOT。

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,依此类推。

ADD login.jsp /var/lib/jetty/webapps/ROOT/Webapps, so on and so forth.

这篇关于Docker Tomcat编辑扩展的War文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆