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

Apache Tomcat container with Podman

- Advertisement -


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

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.

- Advertisement -


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook