Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM quay.io/centos/centos:stream9

LABEL maintainer="emverdes@gmail.com"

RUN dnf install -y java-11-openjdk tomcat && \
dnf install iproute && \
dnf clean all

ADD sample.war /var/lib/tomcat/webapps/

EXPOSE 8080
CMD ["/usr/libexec/tomcat/server", "start"]
7 changes: 0 additions & 7 deletions Dockerfile

This file was deleted.

50 changes: 43 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,49 @@
# 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
* cd 'docker-tomcat-tutorial'
* $docker build -t mywebapp .
* $docker run -p 80:8080 mywebapp
* http://localhost:80
* 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 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 "/sample" "http://localhost:8008/sample"
ProxyPassReverse "/sample" "http://localhost:8008/sample"
```

# Apache proxy loadbalancer for 2 containers
```
<Proxy "balancer://mycluster">
BalancerMember "http://localhost:8008/sample"
BalancerMember "http://localhost:8009/sample"
</Proxy>
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/)