Skip to content

Latest commit

 

History

History
65 lines (42 loc) · 2.6 KB

README.md

File metadata and controls

65 lines (42 loc) · 2.6 KB

DCHQ - Basic Docker Tomcat Example

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.

Clone this project

You can clone this project:

git clone https://github.com/dchqinc/basic-docker-tomcat-example.git

Build an image using the cloned project

cd into the directory of the cloned GitHub project

docker build -t <your-username>/tomcat:latest .

Sign up for an account on Docker Hub and create a public tomcat repository

  • Sign up for a free account on Docker Hub – https://hub.docker.com/

  • Create a public repository called “tomcat”

Push the created image to your Docker Hub repository

docker login
docker push <your-username>/tomcat:latest

Run the container on a Docker-enabled Linux host

docker run -p 8080:8080 -d --name tomcat  <your-username>/tomcat:latest

Access the sample application

You can access the sample application on this URL: http://:8080/sample

Access the logs

You can use this simple command to check the catalina logs of the Tomcat container

docker logs tomcat

Check the files inside the container

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