Identify overlay networks from the inside of the container
I have a process inside my docker container that is attached to multiple overlay networks and it must only bind to a specific overlay network interface (it knows its name through passed env vars) so that the rest of the containers in that overlay network would be able to talk to it.
How can a container identify which one of its given network interfaces is which overlay network interface from the inside?
One Solution collect form web for “Identify overlay networks from the inside of the container”
If you already know the network details then you can run the following inside the container to get the hostname :
This will provide you with the overlay network’s ip.
Another way will be to pass the Network name as a runtime argument , like so :
docker run --name=myname -e NETWORK=MY_NETWORK --net=MY_NETWORK
And inside the container :
echo $NETOWRK MY_NETWORK