Tomcat的Dockerfile [英] Dockerfile for tomcat
问题描述
我需要创建一个包含tomcat安装细节的映像。我尝试了net中的许多dockerfile并尝试构建,但是没有运气。有人可以告诉我成功安装tomcat的dockerfile中应该包含哪些命令吗?。官方的tomcat图像。预先感谢。
I need to create an image with tomcat installation details.I tried many dockerfile in net and tried to build but no luck.Can anybody tell me what commands should be their in dockerfile for a successfull tomcat installation?.I dont need any official tomcat image.Thanks in advance.
推荐答案
这是我为解决此问题所做的工作:
This is what i did to solve this:
Dockerfile
FROM tomcat
MAINTAINER richard
RUN apt-get update && apt-get -y upgrade
WORKDIR /usr/local/tomcat
COPY tomcat-users.xml /usr/local/tomcat/conf/tomcat-users.xml
COPY context.xml /usr/local/tomcat/webapps/manager/META-INF/context.xml
EXPOSE 8080
我正在复制这两个文件,以便从外部访问管理器应用程序。如果也需要,请将以下内容添加到上下文和tomcat用户文件中
I'm copying those two files in order to access the manager app from outside. If you want it too, add the following to your context and tomcat-users files
Context.xml
<Context antiResourceLocking="false" privileged="true" >
<!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
tomcat-users.xml
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<user username="admin" password="secret" roles="manager-gui"/>
</tomcat-users>
然后您可以构建并运行它:
Then you can build it and run it:
docker build -t name/tomcat .
docker run -d -p 8080:8080 --name some_name name/tomcat
部署您的应用程序如下:
Deploy your application as follows:
docker cp some/app.war some_name:/usr/local/tomcat/webapps/app.war
这篇关于Tomcat的Dockerfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!