How to build a Docker container for JAVA web application How to build a Docker container for JAVA web application docker docker

How to build a Docker container for JAVA web application


You need a web server or an application server container like tomcat or Jboss (and many others) to deploy and run your java based web application. Your "techpoint.war" files need to be copied to the specific folder depends on each web server. For example, if you are using Tomcat then you can copy it to the /webapps folder. Tomcat will extract and deploy the war file.You can add the following to your DockerFile.

FROM tomcat:8.5.11-jre8COPY /<war_file_location>/techpoint.war /usr/local/tomcat/webapps/techpoint.war

You can build the image using docker build command and start the container from the created image.

docker build -t techpoint.docker run -it --rm -p 8091:8080 techpoint

Now Tomcat will extract and deploy your war file.How to access the deployed application depends on the webroot of your application. For example,

http://<ip_address>:8091/techpoint/index.html