使用来自Docker的tomcat映像时具有自定义catalina.sh [英] Having a custom catalina.sh when using a tomcat image from Docker

查看:946
本文介绍了使用来自Docker的tomcat映像时具有自定义catalina.sh的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Dockerfile创建Tomcat 6.0.44。看起来像这样:

I'm currently using Dockerfile to create Tomcat 6.0.44. It looks like this:

FROM tomcat:6.0.44-jre7

...

ADD catalina.sh /usr/local/tomcat/bin

构建映像来自Dockerfile的文件很好,但是当我运行它时,出现以下错误:

Building the image from the Dockerfile is fine, but when I go to run it I get the following error:

exec: "catalina.sh": executable file not found in $PATH.

有任何解决方法的想法吗?

Any idea of how to fix this?

我想做的是传入此参数 -DentityExpansionLimit = 100000 。有没有比 catalina.sh 更简单的方法?

What I'm trying to do is pass in this parameter -DentityExpansionLimit=100000. Is there an easier way of doing it than in the catalina.sh?

任何帮助/建议都将不胜感激。

Any help/suggestions would be greatly appreciated.

编辑:
我正在运行EC2上的Redhat实例,并使用Docker扩展了tomcat 6映像。

I'm running a Redhat instance on EC2, and using Docker to extend a tomcat 6 image.

推荐答案

我不知道您是否已经找到一个解决方案,但这是我的建议。如果我对您的理解正确,则希望为Web应用程序设置Java VM选项。另外,您尝试使用自己的版本更改catalina.sh脚本,以便在运行Web应用程序时包含一个附加的Java VM选项。

I don't know if you already found a solution, but here's my suggestion. If I understand you correctly, you'd want to set a Java VM option for your webapp. Also, you try to alter the catalina.sh script with your own version so that it contains an additional Java VM option when running your webapp.

我认为您不应该拥有使用您自己的 catalina.sh 更改图像。脚本catalina.sh查看环境变量。您可以将环境变量CATALINA_OPTS设置为包含此设置。 (还有一个环境变量JAVA_OPTS,但是当您还希望将这些Java选项应用于某些其他Tomcat本地进程(例如,根据tomcat文档的stop进程和版本)时,应使用该变量。)

I think you should not have to alter the image with your own catalina.sh. The script catalina.sh looks at the environment variables. You could set the environment variable CATALINA_OPTS to contain this setting. (There is also an environment variable JAVA_OPTS but that should be used for when you also want to apply these java options to some other Tomcat-native processes such as the stop process and version according to tomcat documentation.)

Tomcat的最新版本(9) catalina.sh 明确指出:

A more recent version of Tomcat (9) catalina.sh explicitly states:

请勿在此脚本中设置变量。而是将它们放入CATALINA_BASE / bin中的脚本setenv.sh中,以使自定义项分开。

因此,您可以选择以下两个选项之一:

So, you could choose one of two options:


  1. 使用Tomcat的标准Docker映像,仅添加您的Web应用程序,而不添加自定义的catalina.sh。运行此图像的容器时,请将CATALINA_OPTS环境变量设置为 -DentityExpansionLimit = 100000 的值。

制作一个 setenv.sh 脚本,该脚本设置CATALINA_OPTS变量。还要将此脚本添加到构建文件中。版本6 catalina.sh 在CATALINA_HOME和CATALINA_BASE文件夹中查找此脚本并执行(如果存在)。像这样(我没有测试过)。

Make a setenv.sh script that sets the CATALINA_OPTS variable. Also add this script in your build file to the image. Version 6 catalina.sh looks for this script in the CATALINA_HOME and CATALINA_BASE folder and executes it if it exists. Something like this (I didn't test it).

#!/bin/sh  
echo "Setting JVM option Entity Expansion limit for application"  
export CATALINA_OPTS="-DentityExpansionLimit=100000"


选项2的优点是您可以将正确的默认JVM选项强制放入映像中,而不是依靠运行映像的人正确设置环境变量。

Option 2 has the advantage that you could force the correct default JVM options into the image instead of relying on people running the image to set the environment variable correctly.

这有意义吗?

这篇关于使用来自Docker的tomcat映像时具有自定义catalina.sh的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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