Deploying Apache Tomcat Workloads on Docker Hosts
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>