Reputation: 51
I have created Docker container and Tomcat is running in this container. How can I deploy a webapp or war file in Tomcat that is running in docker container.
Upvotes: 5
Views: 5364
Reputation: 1817
You can implement an effective way of using Tomcat Docker.
docker run -d -p 80:8080 -v <mount-path>:/usr/local/tomcat/webapps/ tomcat:8.0
And then copy the .war files to the mounted volume. This would eliminate the need for restarting the Tomcat Docker each time when there is a code change. A zero downtime implementation could be achieved.
If it's a one-time deployment then you may create a custom Docker and copy the war file into /usr/local/tomcat/webapps/
and start the Docker.
Upvotes: 3
Reputation: 4669
First create a Dockerfile:
FROM library/tomcat
RUN rm -rf /usr/local/tomcat/webapps/*
ADD ./relative/path_to_war.war /usr/local/tomcat/webapps/ROOT.war
Then build Docker image
$ docker build -t user/image_name .
And finally run docker container.
$ docker run --name container_name -p 80:8080 -d user/image_name
After that your webapp should be responding on Docker host's ip on default http 80 port.
You might need to link a database container to your webapp, see more on Docker documentation
Upvotes: 4