Database WebApp with Wildfly and mySQL in Docker container

  Docker, mySQL, Servlet, Wildfly

Connecting the container

The idea behind the seperate mySQL and Wildfly container is that we don’t need to create a big clumsy one-size-fits-all container but to keep their installation/configuration separate. If any problem arises, we only have to mess with one container.
Currently the two container can’t communicate with each other. We have to put both on the same virtual network in order to enable a web application running on the Wildfly container to access the mysql database.
Docker maintains a default network to which we can add the mySQL and Wildfly container. Alternativly we could create our own network just for the purpose of this tutorial. That’s what we will do now. The following docker command sequence will create a new network and connect both container to it.

docker network create -d bridge my-bridge-network
docker network connect my-bridge-network wildfly25
docker network connect my-bridge-network mysql-server

If you want to check what networks docker just created enter the following commands:

docker network ls
docker network inspect my-bridge-net

LEAVE A COMMENT