Cloud Native 3 min read

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.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Building a Tomcat Docker Image with a Custom Dockerfile

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.rpm

Then 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 8080

After 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/bash

Because 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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DevOpsLinuxContainerTomcatDockerfile
Practical DevOps Architecture
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.