Deploy WAR in Docker tomcat container

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers.

Image for post
Image for post
docker image pull tomcat:8.0
docker image ls # it will list all images in your docker
docker container create --publish 8082:8080 --name my-tomcat-container tomcat:8.0
docker container ls -a # it will list all the containers
docker container start my-tomcat-container
# to get inside your docker tomcat container directory...
docker container exec -it my-tomcat-container bash
# it will list tomcat directory inside your docker as
# :/usr/local/tomcat# ls
# LICENSE NOTICE RELEASE-NOTES RUNNING.txt bin conf include lib # logs native-jni-lib temp webapps work
# we are extending everything from tomcat:8.0 image ...
FROM tomcat:8.0
MAINTAINER your_name# COPY path-to-your-application-war path-to-webapps-in-docker-tomcatCOPY some-app/target/some-app.war /usr/local/tomcat/webapps/
# docker image build -t your_name/some-app location_of_dockerfile
docker image build -t your_name/some-app-image ./
# now if you check list of images in your docker, you will see as
# your_name/some-app-image image in it...
docker image ls# REPOSITORY TAG IMAGE ID CREATED SIZE
# your_name/some-app-image latest 5154ca16b1dd 1 hours ago 421MB
# creating and running a container
docker container run -it --publish 8081:8080 your_name/some-app-image

Java | JavaScript | AWS

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store