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?

  • Overriding image version in docker-compose file
  • HBase 1.2.1 standalone in Docker unable to connect
  • Nginx with dockerized NodeJS
  • When I start my app with PM2 + Docker, just run and exit
  • Unable to run mongod inside ubuntu docker container through ssh (Docker is started using “--net=host”)
  • AWS ECR Authentication Test
  • Puppet-Docker Service Error undefined method '[]' for nil:NilClass
  • Links apps in Docker Swarm Mode
  • Embed code in docker container or mount it as a volume?
  • How to map docker images to a dockerfile?
  • Docker: Error starting container: Unable to load the AUFS module
  • How to configure GWT debugging with docker?
  • 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
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.