Deploying Tomcat with sample web app in Docker container

In this post I would like to continue on the topic of deploying application server, but this time instead of just installing Docker, we will setup a Tomcat app server container with deployed sample web application.

The Ansible playbook is going to be contain content previously wrote for application server purpose, plus some extra stuff added for setting up Docker container. Below you can see the actual playbook:

Compared to previous playbook, I’ve directory to store Dockerfile and commands to build an image from it, start the container and publish it on port 8080.

Let’s take a look at Dockerfile:

Thanks to utilisation of preexisting Tomcat image from Dockerhub, all we need to do is download the .war artifact file for web application deployment, place it in target directory (webapps), make sure that port 8080 is published and start the application server.

After running the playbook and going through it’s steps output looks like the following:

All that is left to do is to make sure that web application is available on application server under port 8080. Let’s go to browser and access it under appserver_address:8080/sample/ URL. You will see following web content:

That’s it! In my next posts I will focus on automating installation of Elastic and Grafana to be utilized in conjuction with application server in later steps.

Leave a Reply

Your email address will not be published. Required fields are marked *