Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Announcing your app from within a container (docker)

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?

  1. 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.
  2. 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?

like image 760
JP. Avatar asked Aug 12 '13 07:08

JP.


1 Answers

I think perhaps the approach to perform the registration of the service after launching the container. Other containers can then perform a registry lookup to discover these services.

Update

The maestro project gives an example of how the containers are configured externally and then launched to setup a cooperating network of containers.

like image 69
Mark O'Connor Avatar answered Oct 03 '22 19:10

Mark O'Connor