用于 tomcat 的 Dockerfile [英] Dockerfile for tomcat

查看:15
本文介绍了用于 tomcat 的 Dockerfile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个带有 tomcat 安装详细信息的图像.我在 net 中尝试了许多 dockerfile 并尝试构建但没有运气.谁能告诉我 dockerfile 中应该使用哪些命令才能成功安装 tomcat?我不需要任何命令官方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-users 文件中

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屋!

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