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?

  • Connection refused between linked Docker containers in a custom network?
  • root password inside a docker container
  • How to solve Docker permission error when trigger by Jenkins
  • Cannot install RWeka package in docker image
  • How to setup docker to talk to non-dockerized service on same host
  • What files are the .dockerignore work on?
  • How to mount network location in docker
  • Pyside fail to show tooltip and specific events in Linux
  • Increase HDFS configured capacity inside Docker
  • NodeJS microservices
  • Docker Permission Denied Only on RHEL 6.6
  • Is MariaDB data lost after Docker setting change?
  • 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.