I have built a solution of 3 docker containers and they all can communicate with each other by resolving using the container names as provided through the hosts file.
The solution is deployed on a machine that already hosts a mysql database and we need to connect to this host machine database to perform specific queries.
We don’t always know what the hosts IP address is going to be (we have a number of hosts this container may be deployed to). Is there any way of getting docker to put the host IP address into the container hosts files?
The other alternative i’ve thought of is passing the host IP address into the container via an environment variable and then getting the container to add it to the hosts file when the container starts up.
Any thoughts?
Cheers,
Kevin