How to let Docker containers broadcast their IP addresses or hostnames to each other?
One aspect of Docker that has always made me thinking is what’s the appropriate way to let different containers that collectively make up an application’s architecture about each others IPs and host names.
So let’s pretend that we have a Docker deployment topology similar to this:
Each orange node represents a Container. All the containers might be running on the same physical machine or each container might have its dedicated EC2 instance. It is also possible that all Author nodes reside on one EC2 instance, and all the Publisher nodes on their own EC2 instance.
But for the sake of this question, we can assume that they are all running on a Developer’s local machine, or each one is running on its own dedicated EC2 instance.
How can I let all of the instances get IP addresses and/or hostnames of all the other instances as they come and go?
So when Author 2 dies, Author 1, Author N, as well as Publisher 1,2 and N should be notified of this event. Similarly, when a new Publisher joins the topology, all other instances should be notified of its IP address and/or hostname.
I am looking for a solution for both my local development environment, as well as one that’s suitable for a production AWS deployment. Ideally, the same solution should work both locally and on AWS.
One Solution collect form web for “How to let Docker containers broadcast their IP addresses or hostnames to each other?”
ETCd is exactly what you want. AWS doesn’t support any sort of multicast or broadcast traffic on their native network. Etcd which is part of CoreOS gives you a framework for service discovery. It allows you to discover nodes along with registering nodes.