How do I get docker containers to talk to an unblocked application?

I have a situation where docker containers need to talk to an unblocked application and docker containers on a different host.

Let's say there are three servers A, B, and C. Server A has two docker containers running JBoss App Server containers. Server B, non-docker node has MySQL DB. Server C has a different set of containers.

I want the JBoss application server container to connect to a MySQL DB residing on a different host and retrieve information from the DB. JBoss also needs to talk to containers located on server C.

How to do it?

PS: I am new to Docker

+3


source to share


1 answer


Containers on the bridged / custom bridge network can automatically access the outside world. This is done through IP masking and Docker will take care of that.

  • mysql db is on server B
  • server A has a route to access server B where mysql db is running.
  • 2 containers are on server A

assuming above, 2 containers should be able to reach mysql db.



There is another related FAQ about containers accessing a service on localhost. You can link to this discussion here ( From within a Docker container, how can I connect to the localhost of the machine? )

Answer to updated question:

When you put a container on an overlay network in swarm mode, it also creates a bridge network (docker_gwbridge). This bridge is created by default for external access. You are correct that in this case the container is part of the overlay and bridge network. Using an overlay network, containers on server A can talk to containers on server C. For a container on server A, to access the DB (non-containerized application) you just need the IP address and port of the database, which you can directly access from inside the container. The DB IP is reachable from Server A, it will also be reachable from inside the container running on Server A using the bridge network. You don't need any special DNS flag or whatever.

+4


source







All Articles