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?

  • Error: docker daemon is not running. [/bin/lib/functions.plugin.sh:93]
  • Docker performances for getting information: polling vs events
  • Can't connect to Docker container
  • Can I use Windows 10 Insider preview to build a docker image
  • docker: freeze library dependencies
  • “Error: The `libsass` binding was not found…” in nodejs 4.2.4 lts but not 5.4.1 using docker
  • Upgrade of docker gitlab image to 8.6 breaks gitlab
  • running bazel remote executor test on separate machines
  • docker exec command doesn't return after completing execution
  • Docker: why installing a linux dist inside the container?
  • How to let two docker containers can ping each other
  • find docker containers created using a docker image
  • 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 :

    hostname -i
    

    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
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.