Dockerized service giving docker's internal IP to external services

I am running some services on docker that announce their ips to services running in other machines.

Some of those services (like spark) can use hostnames and work just fine. Unfortunately some services REALLY insist in handing ip addresses out and this breaks my system since the internal docker ip is not reachable. i cant just force the services to use the public ip address because they will not find the interface to bind to.

I attempted to circumvent this by creating a custom network and assigning the host’s ip to the container. unfortunately doing so made the container lose internet access. i also noticed that if i assigned a /23 network and did not specify the ip address docker always avoids the same /24 domain.

any known solutions for this issue?

I have been fighting an application that does this for the last few years
there is no magic… you can try to use an overlay network, like Weave, but it requires YOU to manage the IP addresses (no DHCP support).

I haven’t found any other way to make these bad apps behave
(my problem app also hard codes the port number, so I can’t host multiple containers on the same host… booo

I managed to get around this problem by setting the container’s ip to the public ip of a load balancer i was not using.

On the load balancer i just redirected the target port to the correct machine. This is a terrible solution but the only one that worked so far