Building a Tomcat Docker Image with a Custom Dockerfile
This guide demonstrates how to create a Docker image for Apache Tomcat on CentOS by preparing a Dockerfile that installs JDK, adds Tomcat binaries, sets an ENTRYPOINT to start the server, and exposes port 8080 for containerized deployment.
The article provides step‑by‑step instructions for building a Docker image that runs Apache Tomcat on a CentOS base.
First, the author shows the file layout on the host machine, including the Tomcat archive and JDK RPM:
-rw-r--r-- 1 root root 9122588 Nov 6 20:41 apache-tomcat-8.0.26.tar.gz -rw-r--r-- 1 root root 102957056 Nov 6 20:57 jdk-8u45-linux-x64.rpmThen the complete Dockerfile is presented:
FROM centos MAINTAINER hahashen RUN yum install wget -y ADD jdk-8u45-linux-x64.rpm /usr/local/ ADD apache-tomcat-8.0.26.tar.gz /usr/local/ RUN cd /usr/local && rpm -vhi jdk-8u45-linux-x64.rpm RUN mv /usr/local/apache-tomcat-8.0.26 /usr/local/tomcat ENTRYPOINT /usr/local/tomcat/bin/startup.sh && tail -F /usr/local/tomcat/catalina.out EXPOSE 8080After saving the file, the image is built with: docker build -t="tomcat:v1" . The resulting image can be verified: docker images | grep tomcat And a container is started, mapping host port 8080 to the container:
docker run -itd -p 8080:8080 --name tomcat01 tomcat:v1 /bin/bashBecause the container needs to launch Tomcat, the ENTRYPOINT line runs the Tomcat startup script and tails the log so the container stays alive.
The author also notes that JDK environment variables could be added using the ENV instruction if desired.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
