A Docker container can be connected to multiple Docker networks, say a public and an internal network.
How can I tell a server - maybe a reverse proxy - to only listen on the IP which belongs to one specific interface?
I can use tools like “ifconfig” to detect the IPs of the container, but as far as I know, I can not know which IP belongs to which Docker network. When the container is running, I can use “docker inspect” to get the mapping between network and IP - but I need that information during container startup.
I could pass the Subnet value of the network as an environment parameter inside the container to be able to choose the right IP. This looks like a lot of overhead - is there a simpler solution?