I asked this question at docker's IRC over the weekend but had to head off before I'd thought through the answers:
If I have a number of applications running in containers (let's, for the moment, assume they're all running on the same physical hardware, but that needn't be the case) and I want each of them to be able to find each other automatically.
Using some sort of registry (eg. etcd or DNS-SD/Bonjour) you could announce your service and any pertinent details and have the other applications find out about them and route traffic accordingly.
The problem here is that while an application can know which hostname/port it is serving on within a container, this needn't be the port or address it's accessible from. There are two bits of information which need to be joined up:
- Where the service can be accessed; accessible from outside the container
- What the service does (version number, type of service); accessible from inside the container
How would you recommend I get this information across the container barrier?
- I could expose docker over TCP to the containers, so an app can query where its showing, but this seems to violate the separation of concerns.
- I could have a file/port open in my container which the host system queries after a container is started in to prepare for an announce, but this feels a bit like I'd be reinventing the WSDL.
Any thoughts or guidance as to how I should solve this problem?