1

I am in process to dockerize my local server, on that have databases, application servers and all additional configuration to deploy my applications. Currently, i have created 3 docker containers that run application servers like Tomcat or WildFly, and exposed 80, 8130 and 8080 ports this deployed applications are in Java and read and write data from/to my local database. On the persistence.xml file for each app, i have configured the access via localhost in my actual configuration that works ok without docker.

I want to connect the apps on the containers to database that correspond on the host machine, how can i do that?

I have created the containers like this:

docker run -d --name app_server1 -p 80:80 wildfly_website:1.0
docker run -d --name app_server2 -p 8130:8130 geoserver:1.0

This image illustrates what i want to do enter image description here

davids182009
  • 441
  • 3
  • 7
  • 26

1 Answers1

1

It sounds like the access you specified in your persistence.xml file are trying to access those ports inside the docker container. You want to access those ports outside the container on your host machine, not what the image thinks is it's localhost which is actually your docker container.

Check these SO posts out which go into pretty good detail of ways to solve this.

Link 1

Link 2

Rob Schwartz
  • 192
  • 1
  • 12