Docker 将 warfile 添加到官方 Tomcat 镜像 [英] Docker add warfile to official Tomcat image

查看:24
本文介绍了Docker 将 warfile 添加到官方 Tomcat 镜像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过运行此命令为 Tomcat 提取了官方 Docker 映像.

I pulled official Docker image for Tomcat by running this command.

docker run -it --rm tomcat:8.0

通过使用它作为基础图像,我需要在 tomcat webapps 文件夹中构建包含我的 war 文件的新图像.我是这样创建 Dockerfile 的.

By using this as base image I need to build new image that contains my war file in the tomcat webapps folder. I created Dockerfile like this.

From tomcat8
ADD warfile /usr/local/tomcat

当我通过构建镜像运行这个 Dockerfile 时,我看不到 Tomcat 的首页.

When I run this Dockerfile by building image I am not able to see Tomcat front page.

谁能告诉我如何将我的warfile添加到官方Tomcat图像webapp文件夹中.

Can anybody tell me how to add my warfile to official Tomcat images webapp folder.

推荐答案

阅读 repo 的文档,你会做类似的事情

Reading from the documentation of the repo you would do something like that

FROM tomcat
MAINTAINER xyz

ADD your.war /usr/local/tomcat/webapps/

CMD ["catalina.sh", "run"]

然后使用 docker build -t yourName <path-to-dockerfile>

然后运行它:

docker run --rm -it -p 8080:8080 yourName

  • --rm 停止后立即移除容器
  • -p 将端口转发到您的主机(或者如果您使用 boot2docker 到此 IP)
  • -it 允许交互模式,因此您可以查看是否部署了某些东西
    • --rm removes the container as soon as you stop it
    • -p forwards the port to your host (or if you use boot2docker to this IP)
    • -it allows interactive mode, so you see if something get's deployed
    • 这篇关于Docker 将 warfile 添加到官方 Tomcat 镜像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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