Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy webapp or war file in tomcat that is running in docker container

Tags:

docker

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.

like image 685
Vijaya Kumar Ganpur Avatar asked Mar 15 '23 01:03

Vijaya Kumar Ganpur


1 Answers

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

like image 80
Lauri Avatar answered Apr 28 '23 23:04

Lauri