Database WebApp with Wildfly and mySQL in Docker container

  Docker, mySQL, Servlet, Wildfly

Let me show you a good approach for developing/running a web application for showing records from a database table on a web page. All you need is a web container and a database server. Of course you could install both on your development workstation (and potentially pollute your system configuration/registry or permanently put stress on the CPU-Load). But often you don’t have dedicated server hardware available so you have to limit yourself to your Windows or Linux development workstation. In such a case (and many more) it is best practise to use “container” in order to keep the server envrironments seperate from your workstation. These container will hold the complete appserver or database engine installation, ready to start them up and make use of them. If not needed, you just stop the container and everything will be back to normal.

We will use Docker to accomplish that. In sync with the Docker philosophy we will create two seperate containers for Wildfly and mySQL.

There is a bunch of web technologies to choose from for designing a dynamic web page which acquires data from a database. For this article, I had three options for which my skill level would suffice. I will cover all three in this article:

– A servlet
– A plain HTMl / JSP page

Prerequisites

Let’s talk about the software components you need for running wildfly and mySQL in container. Make sure you have following software properly installed on your workstation:

  • Java 1.8 JDK or higher
  • Docker (Windows)
  • Eclipse IDE for Enterprise Java and Web Developers
  • mySQL Workbench

I assume you already have a Java JDK installation and have at least some experience using it with Eclipse or some other IDE. If not, this article might exceed your skill level by a magnitude. If you don’t have Docker yet, download it from https://docs.docker.com/desktop/windows/install/. In the course of this article I assume that you have a Windows based development workstation, so download Docker Desktop for Windows. The major obstacle here is that Docker needs a virtualization environment which requires you to either use WSL2 or Hyper-V. The Docker download page covers both szenarios. For newbies I recommend to go for WSL2.

When that’s out of the way, you are ready to create your first container.

LEAVE A COMMENT