Apache Tomcat container with Podman

Introduction

The Apache Tomcat container software is developed in an open-source and participatory environment under the Apache License version 2. The Apache Tomcat project is intended to be a collaboration of the best-of-breed developers from around the world. We invite you to participate in this open development project. To learn more about getting involved, click here or keep reading. You can also check Tomcat 10 installation tutorial.

Pull an image from registry

# podman search tomcat --filter=is-official
# podman pull docker.io/library/tomcat

Create Apache tomcat container pod

# podman pod create --name tomcatapp -p 8080:8080 --network bridge

Run a container based on Tomcat image downloaded

Here we have initiated a container for the tomcat image and exposed the port 8080 of the tomcat container on port 8080 of localhost using port forwarding. The list of all containers that are available can be shown using the ps option for podman.

# podman run --pod tomcatapp --name tomcat-server -d tomcat:9.0
# podman ps

Fixing error 404

Here is the solution to fix the issue.

# podman exec -it tomcat-server /bin/bash
# mv webapps webapps2
# mv webapps.dist/ webapps
# exit

Persisting your application

If you remove the container all your data and configurations will be lost, and the next time you run the image the database will be reinitialized. To avoid this loss of data, you should mount a volume that will persist even after the container is removed.

For persistence, you should mount a directory at the  /usr/local/tomcat  path. If the mounted directory is empty, it will be initialized on the first run.

The default Tomcat environment in the image is:

CATALINA_BASE:   /usr/local/tomcat
CATALINA_HOME:   /usr/local/tomcat
CATALINA_TMPDIR: /usr/local/tomcat/temp
JRE_HOME:        /usr
CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

The configuration files are available in /usr/local/tomcat/conf/. No user is included in the “manager-GUI” role to operate the “/manager/html” application. If you wish to use this app, you must define such a user in tomcat-users.xml.

Apache Tomcat image maintainers have chosen not to enable the default applications as a security precaution, but with two custom configuration files and overriding the Docker command, it is possible to boot Tomcat with a fully functional manager application.

This post provided example configuration files and the podman command to restore the default applications before running Tomcat.

Neil
Treat your password like your toothbrush. Don’t let anybody else use it, and get a new one every six months.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

You might also likeRELATED

1 DNS server container Podman dirty easy

Introduction Linux distributions. So, what is a DNS? A DNS server is a service that helps resolve a fully qualified domain name (FQDN) into an IP address...

1 Nagios xi server container Fast and Easy

Introduction Provides monitoring of all mission-critical infrastructure components, including applications, services, operating systems, network protocols, systems metrics, and network infrastructure. In addition, hundreds of third-party...

Remote VS Code fast and dirty easy 100%

Introduction Visual Studio Code or VS Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows,...