From fe06709634b53ce52874a02f695de7f22d63ece2 Mon Sep 17 00:00:00 2001 From: Enrique Verdes Date: Wed, 9 Mar 2022 22:47:11 -0300 Subject: [PATCH 01/11] Cambios en Dockerfile y README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit En Dockerfile - cambiamos la imagen base a Centos 8 Stream - instalamos openjdk - bajamos Tomcat y lo instalamos - ejecutamos tomcat En README.md - Cambiamos link de instalación de docker a podman - Cambiamos referencias a docker por podman - Agregamos ejecución de otra instancia de contenedor para balanceo - Agregamos configuración de balanceador con mod_proxy_balancer en apache - Agregamos configuración de SELinux para balanceo. --- Dockerfile | 15 +++++++++++---- README.md | 27 +++++++++++++++++++++------ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index a259ddc..12e670d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,14 @@ -FROM tomcat:8.0-alpine -LABEL maintainer="deepak@softwareyoga.com" +FROM quay.io/centos/centos:stream8 -ADD sample.war /usr/local/tomcat/webapps/ +LABEL maintainer="emverdes@gmail.com" + +RUN dnf install -y java-1.8.0-openjdk && yum clean all + +RUN mkdir /opt/tomcat + +RUN curl -O https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.76/bin/apache-tomcat-8.5.76.tar.gz && tar xvfz apache*.tar.gz && mv apache-tomcat-8.5.76/* /opt/tomcat/. + +ADD sample.war /opt/tomcat/webapps/ EXPOSE 8080 -CMD ["catalina.sh", "run"] \ No newline at end of file +CMD ["/opt/tomcat/bin/catalina.sh", "run"] diff --git a/README.md b/README.md index 53170c6..ea489a9 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,28 @@ # docker-tomcat-tutorial -A basic tutorial on running a web app on Tomcat using Docker +A basic tutorial on running a web app on Tomcat using Podman (based on a docker tutorial) # Steps -* Install [Docker](https://docs.docker.com/install/). -* Clone this repository - $git clone https://github.com/softwareyoga/docker-tomcat-tutorial.git +* Install [podman] (https://podman.io/getting-started/installation). +* Clone this repository - $git clone https://github.com/emverdes/docker-tomcat-tutorial.git * cd 'docker-tomcat-tutorial' -* $docker build -t mywebapp . -* $docker run -p 80:8080 mywebapp -* http://localhost:80 +* $podman build -t tomcat-demo:1 . +* $podman run -p 8008:8080 --name demo1 tomcat-demo:1 +* http://localhost:8008 +* Run another instance for load balancing $podman run -p 8009:8080 --name demo1 tomcat-demo:1 + +# Apache proxy loadbalancer + + BalancerMember "http://localhost:8008/sample" + BalancerMember "http://localhost:8009/sample" + +ProxyPass "/" "balancer://mycluster/" +ProxyPassReverse "/" "balancer://mycluster/" + + +# For reverse proxy +* #setsebool -P httpd_can_network_connect on +* #setsebool -P httpd_can_network_relay on + # Links [Sample Tomcat web app](https://tomcat.apache.org/tomcat-8.0-doc/appdev/sample/) From 707bd3845be1f1ca212baa0b79323fa383790483 Mon Sep 17 00:00:00 2001 From: Enrique Verdes <49655203+emverdes@users.noreply.github.com> Date: Sat, 22 Apr 2023 17:28:03 -0300 Subject: [PATCH 02/11] Update Dockerfile Update tomcat URL. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 12e670d..7ff9bcc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ RUN dnf install -y java-1.8.0-openjdk && yum clean all RUN mkdir /opt/tomcat -RUN curl -O https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.76/bin/apache-tomcat-8.5.76.tar.gz && tar xvfz apache*.tar.gz && mv apache-tomcat-8.5.76/* /opt/tomcat/. +RUN curl -O https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.88/bin/apache-tomcat-8.5.88.tar.gz && tar xvfz apache*.tar.gz && mv apache-tomcat-8.5.76/* /opt/tomcat/. ADD sample.war /opt/tomcat/webapps/ From 767c0ab22721a6d564e202f5dfc226fe0cdb6526 Mon Sep 17 00:00:00 2001 From: Enrique Verdes <49655203+emverdes@users.noreply.github.com> Date: Sat, 22 Apr 2023 17:29:31 -0300 Subject: [PATCH 03/11] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ea489a9..3ef7d86 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ A basic tutorial on running a web app on Tomcat using Podman (based on a docker * Install [podman] (https://podman.io/getting-started/installation). * Clone this repository - $git clone https://github.com/emverdes/docker-tomcat-tutorial.git * cd 'docker-tomcat-tutorial' +* Verify Tomcat download URL from https://dlcdn.apache.org/tomcat/ to update the Dockerfile * $podman build -t tomcat-demo:1 . * $podman run -p 8008:8080 --name demo1 tomcat-demo:1 * http://localhost:8008 From 8bce2fb30be8ebe24021a384dfa6d247670bf00b Mon Sep 17 00:00:00 2001 From: Enrique Verdes Date: Mon, 29 May 2023 17:09:54 -0300 Subject: [PATCH 04/11] Correcciones de errores MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Se corrigió un error en el Dockerfile con la versión de tomcat Se corrigió en el README el formato de la configuración del reverse proxy. --- Dockerfile | 4 ++-- README.md | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7ff9bcc..19641f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,11 @@ FROM quay.io/centos/centos:stream8 LABEL maintainer="emverdes@gmail.com" -RUN dnf install -y java-1.8.0-openjdk && yum clean all +RUN dnf install -y java-1.8.0-openjdk && dnf clean all RUN mkdir /opt/tomcat -RUN curl -O https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.88/bin/apache-tomcat-8.5.88.tar.gz && tar xvfz apache*.tar.gz && mv apache-tomcat-8.5.76/* /opt/tomcat/. +RUN curl -O https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.88/bin/apache-tomcat-8.5.88.tar.gz && tar xvfz apache*.tar.gz && mv apache-tomcat-8.5.88/* /opt/tomcat/. ADD sample.war /opt/tomcat/webapps/ diff --git a/README.md b/README.md index 3ef7d86..599a86d 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,14 @@ A basic tutorial on running a web app on Tomcat using Podman (based on a docker * Run another instance for load balancing $podman run -p 8009:8080 --name demo1 tomcat-demo:1 # Apache proxy loadbalancer +``` BalancerMember "http://localhost:8008/sample" BalancerMember "http://localhost:8009/sample" ProxyPass "/" "balancer://mycluster/" ProxyPassReverse "/" "balancer://mycluster/" - +``` # For reverse proxy * #setsebool -P httpd_can_network_connect on From 92d254683a5798468782571a9cf051a13b1a35fa Mon Sep 17 00:00:00 2001 From: Enrique Verdes <49655203+emverdes@users.noreply.github.com> Date: Tue, 30 May 2023 19:49:41 -0300 Subject: [PATCH 05/11] Update README.md with simple reverse proxy Added simple reverse proxy configuration for a single container. --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 599a86d..d0042bf 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,14 @@ A basic tutorial on running a web app on Tomcat using Podman (based on a docker * http://localhost:8008 * Run another instance for load balancing $podman run -p 8009:8080 --name demo1 tomcat-demo:1 -# Apache proxy loadbalancer +# Simple apache reverse proxy + +``` +ProxyPass "/" "http://localhost:8008/sample" +ProxyPassReverse "/" "http://localhost:8008/sample" +``` + +# Apache proxy loadbalancer for 2 containers ``` BalancerMember "http://localhost:8008/sample" From 444810ca57ed506d6adb1cea6055a05a0b9403ec Mon Sep 17 00:00:00 2001 From: Enrique Verdes <49655203+emverdes@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:29:00 -0300 Subject: [PATCH 06/11] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrección de enlace --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0042bf..7f97e4a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A basic tutorial on running a web app on Tomcat using Podman (based on a docker tutorial) # Steps -* Install [podman] (https://podman.io/getting-started/installation). +* Install [podman](https://podman.io/getting-started/installation). * Clone this repository - $git clone https://github.com/emverdes/docker-tomcat-tutorial.git * cd 'docker-tomcat-tutorial' * Verify Tomcat download URL from https://dlcdn.apache.org/tomcat/ to update the Dockerfile From e39ab2d428f89328db259feb91b14661fe257b64 Mon Sep 17 00:00:00 2001 From: Enrique Verdes Date: Fri, 21 Jun 2024 12:43:52 -0300 Subject: [PATCH 07/11] Actualizacion del proyecto y algunas correcciones. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Se cambia el Dockerfile por Containerfile, y se actualiza para usar Centos Stream 9, OpenJDK 11 y la última versión de Tomcat 8. Se mejora el README.md para que sea más legible y consistente y se aclaran algunos puntos. --- Containerfile | 14 ++++++++++++++ Dockerfile | 14 -------------- README.md | 30 +++++++++++++++++++++--------- 3 files changed, 35 insertions(+), 23 deletions(-) create mode 100644 Containerfile delete mode 100644 Dockerfile diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..9a51ba2 --- /dev/null +++ b/Containerfile @@ -0,0 +1,14 @@ +FROM quay.io/centos/centos:stream9 + +LABEL maintainer="emverdes@gmail.com" + +RUN dnf install -y java-11-openjdk && dnf clean all + +RUN mkdir /opt/tomcat + +RUN curl -O https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.100/bin/apache-tomcat-8.5.100.tar.gz && tar xvfz apache*.tar.gz && mv apache-tomcat-8.5.100/* /opt/tomcat/. + +ADD sample.war /opt/tomcat/webapps/ + +EXPOSE 8080 +CMD ["/opt/tomcat/bin/catalina.sh", "run"] diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 19641f9..0000000 --- a/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM quay.io/centos/centos:stream8 - -LABEL maintainer="emverdes@gmail.com" - -RUN dnf install -y java-1.8.0-openjdk && dnf clean all - -RUN mkdir /opt/tomcat - -RUN curl -O https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.88/bin/apache-tomcat-8.5.88.tar.gz && tar xvfz apache*.tar.gz && mv apache-tomcat-8.5.88/* /opt/tomcat/. - -ADD sample.war /opt/tomcat/webapps/ - -EXPOSE 8080 -CMD ["/opt/tomcat/bin/catalina.sh", "run"] diff --git a/README.md b/README.md index 7f97e4a..179b863 100644 --- a/README.md +++ b/README.md @@ -3,19 +3,31 @@ A basic tutorial on running a web app on Tomcat using Podman (based on a docker # Steps * Install [podman](https://podman.io/getting-started/installation). -* Clone this repository - $git clone https://github.com/emverdes/docker-tomcat-tutorial.git -* cd 'docker-tomcat-tutorial' -* Verify Tomcat download URL from https://dlcdn.apache.org/tomcat/ to update the Dockerfile -* $podman build -t tomcat-demo:1 . -* $podman run -p 8008:8080 --name demo1 tomcat-demo:1 -* http://localhost:8008 -* Run another instance for load balancing $podman run -p 8009:8080 --name demo1 tomcat-demo:1 +* Clone this repository +``` +$ git clone https://github.com/emverdes/docker-tomcat-tutorial.git + +$ cd docker-tomcat-tutorial +``` +* Verify Tomcat download URL from https://dlcdn.apache.org/tomcat/ to update the Containerfile +``` +$ podman build -t tomcat-demo:1 . +$ podman run -p 8008:8080 --name demo1 tomcat-demo:1 +``` +* In your browser go to http://localhost:8008 +* Run another instance for load balancing +``` +$ podman run -p 8009:8080 --name demo1 tomcat-demo:1 +``` # Simple apache reverse proxy +Add to a VirtualHost in your apache web server configuration. +Replace localhost with the hostname of the host running your containers. +Remember to open up the ports in your firewall if needed. ``` -ProxyPass "/" "http://localhost:8008/sample" -ProxyPassReverse "/" "http://localhost:8008/sample" +ProxyPass "/sample" "http://localhost:8008/sample" +ProxyPassReverse "/sample" "http://localhost:8008/sample" ``` # Apache proxy loadbalancer for 2 containers From 7d92ebed802d3f3df5450347d1f1bc81bc357bc7 Mon Sep 17 00:00:00 2001 From: Enrique Verdes <49655203+emverdes@users.noreply.github.com> Date: Mon, 23 Jun 2025 19:41:54 -0300 Subject: [PATCH 08/11] Update Containerfile Install tomcat from package Install iproute so we can inspect networkin Changed route for deploying sample app Changed container run. --- Containerfile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Containerfile b/Containerfile index 9a51ba2..2686e43 100644 --- a/Containerfile +++ b/Containerfile @@ -2,13 +2,11 @@ FROM quay.io/centos/centos:stream9 LABEL maintainer="emverdes@gmail.com" -RUN dnf install -y java-11-openjdk && dnf clean all +RUN dnf install -y java-11-openjdk tomcat && \ + dnf install iproute && \ + dnf clean all -RUN mkdir /opt/tomcat - -RUN curl -O https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.100/bin/apache-tomcat-8.5.100.tar.gz && tar xvfz apache*.tar.gz && mv apache-tomcat-8.5.100/* /opt/tomcat/. - -ADD sample.war /opt/tomcat/webapps/ +ADD sample.war /var/lib/tomcat/webapps/ EXPOSE 8080 -CMD ["/opt/tomcat/bin/catalina.sh", "run"] +CMD ["/usr/libexec/tomcat/server start", "start"] From 717d5fc8f6b39c97dfd71addccbc220c075b4d7c Mon Sep 17 00:00:00 2001 From: Enrique Verdes <49655203+emverdes@users.noreply.github.com> Date: Mon, 23 Jun 2025 21:32:57 -0300 Subject: [PATCH 09/11] Update Containerfile Corrected typo in CMD. --- Containerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Containerfile b/Containerfile index 2686e43..7442b13 100644 --- a/Containerfile +++ b/Containerfile @@ -9,4 +9,4 @@ RUN dnf install -y java-11-openjdk tomcat && \ ADD sample.war /var/lib/tomcat/webapps/ EXPOSE 8080 -CMD ["/usr/libexec/tomcat/server start", "start"] +CMD ["/usr/libexec/tomcat/server", "start"] From cf254e890fe211c0cda562e9da309e760c8d9545 Mon Sep 17 00:00:00 2001 From: Enrique Verdes <49655203+emverdes@users.noreply.github.com> Date: Wed, 4 Mar 2026 21:13:04 -0300 Subject: [PATCH 10/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 179b863..bfe6883 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# docker-tomcat-tutorial +# Podman+Tomcat tutorial A basic tutorial on running a web app on Tomcat using Podman (based on a docker tutorial) # Steps From 9f8599008a26f2b4f1efa84fca8a050a7a20c3ab Mon Sep 17 00:00:00 2001 From: Enrique Verdes <49655203+emverdes@users.noreply.github.com> Date: Wed, 4 Mar 2026 21:14:48 -0300 Subject: [PATCH 11/11] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bfe6883..4ef8d7e 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,12 @@ $ git clone https://github.com/emverdes/docker-tomcat-tutorial.git $ cd docker-tomcat-tutorial ``` -* Verify Tomcat download URL from https://dlcdn.apache.org/tomcat/ to update the Containerfile +Build the image ``` $ podman build -t tomcat-demo:1 . - +``` +Run the image +``` $ podman run -p 8008:8080 --name demo1 tomcat-demo:1 ``` * In your browser go to http://localhost:8008