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

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

问题描述

  docker run -it --rm tomcat:8.0 

通过使用它作为基本图像,我需要在<$ c中构建包含我的war文件的新图像$ c> tomcat webapps 文件夹。我创建了这样的Dockerfile。

 从tomcat8 
添加warfile / usr / local / tomcat

当我通过构建映像运行这个Dockerfile时,我无法看到Tomcat的首页。



任何人都可以告诉我如何将warfile添加到官方Tomcat图像webapp文件夹中。

解决方案

文件记录你会做这样的事情

  FROM tomcat 
维护者xyz

添加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 将端口转发到你的hos (或者如果你使用boot2docker到这个IP)

  • -it 允许交互模式,所以你看看是否有东西被部署了


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

docker run -it --rm tomcat:8.0

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

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

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

解决方案

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"]

Then build your image with docker build -t yourName <path-to-dockerfile>

And run it with:

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

  • --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天全站免登陆