I have dockerized my spring boot app. While running the docker container for the app I pass ip of one of the infra host as --add-host=infra.host:<ip address>
.
When the container is up, I can see the entry in /etc/hosts
file which shows as:
127.0.0.1 localhost
<ip address> infra.host
But my application is not able to establish a connection with this infra, because it is trying to establish a connection with ip "infra.host:<port>"
. Which means that when using the ---add-host
during the docker run
command, it is successfully making the entry in /etc/hosts
but the application is not able to resolve to that ip.
What could be the reason for this ? Help appreciated.