Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
307 views
in Technique[技术] by (71.8m points)

boot2docker - Docker add warfile to official Tomcat image

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...