This is the most basic Docker Tomcat example to demonstrate how an image is built using a Dockerfile that copies a sample Java WAR file. Once you build your own Tomcat image, you can push it to your Docker Hub repository and then run a container using this image on any Linux host that is Docker-enabled.
You can clone this project:
git clone https://github.com/dchqinc/basic-docker-tomcat-example.git
cd into the directory of the cloned GitHub project
docker build -t <your-username>/tomcat:latest .
-
Sign up for a free account on Docker Hub – https://hub.docker.com/
-
Create a public repository called “tomcat”
docker login
docker push <your-username>/tomcat:latest
docker run -p 8080:8080 -d --name tomcat <your-username>/tomcat:latest
You can access the sample application on this URL: http://:8080/sample
You can use this simple command to check the catalina logs of the Tomcat container
docker logs tomcat
You can run this command to enter the container and check the files under the webapps directory
docker exec -it tomcat bash
ls -lrt /usr/local/tomcat/webapps