Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Deploying Apache Tomcat Workloads on Docker Hosts

Tech 1

Package Management

For RHEL and CentOS systems, invoke the package manager:

yum install docker -y

Debian and Ubuntu distributions utilize the following commands:

apt-get update && apt-get install docker.io -y

Resolving Dependency Locks

If installation halts due to repository conflicts, identify the blocking process.

ps aux | grep yum

Terminate the associated Process ID (PID) to release the lock:

kill -9 <PID>

Verification and Service Initiation

Check the daemon integrity and version string:

docker --version

Enable and start the background service:

systemctl enable docker && systemctl start docker

Initial Environment Test

Retreive the diagnostic image from the registry to confirm connectivity:

docker pull hello-world

Execute the container instance:

docker run hello-world

Terminal output indicating successful client-daemon interaction confirms a functional environment.

Tomcat Container Configuration

Image Acquisition

Search for available server images within the public registry:

docker search tomcat

Select an official variant and download the speciifc version tag:

docker pull tomcat:8.5.75

Inspect local artifact cache:

docker images grep tomcat

Execution Strategies

Standard launch maps the host interface to the default HTTP port:

docker run -d -p 8080:8080 tomcat:8.5.75

Access the web server via http://<HOST_IP>:8080.

To serve custom static artifacts, bind a host directory to the container's deployment path:

docker run -d \
  -p 8080:8080 \
  -v $(pwd)/webapp/:/usr/local/tomcat/webapps/custom \
  tomcat:8.5.75

This command mounts the local webapp folder into the Tomcat instance while exposing the correct network port.

Lifecycle Management

Common operations for managing runtime containers:

# List active instances
docker ps

# Access interactive shell inside running container
docker exec -it <CONTAINER_ID> bash

# Stop specific container by ID
docker stop <CONTAINER_ID>

# Remove stopped containers
docker rm <CONTAINER_ID>

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

SBUS Signal Analysis and Communication Implementation Using STM32 with Fus Remote Controller

Overview In a recent project, I utilized the SBUS protocol with the Fus remote controller to control a vehicle's basic operations, including movement, lights, and mode switching. This article is aimed...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.