signalfuse/maestro-ng — pull request #1 by jpfuentes2 (2013-12-24 16:07:27+00:00)
Title: Allow containers to bind to ship IP instead of only 0.0.0.0

First, let me say thank you for the awesome tool you've created!

Onto the important bit:

```
Finally, Maestro makes the choice of using one-to-one port mappings from
the container to the host. This _may_ change in the future, but for now
this simplifies things:

* it means Maestro doesn't have to do a lot of introspection on the
containers to figure out which external port Docker assigned them;
* it makes it a bit easier for troubleshooting as port numbers are the
same inside and outside the containers;
* some services (Cassandra is one example) assume that all their nodes
use the same port(s).
```

I agree that it greatly simplifies things for your code **and** for users, however, I have a slight issue with this because: I want to iterate and build my Docker images/formation using maestro in a Vagrant VM before I ship to production.

Side note: we've actually talked on IRC about Docker overhead and discussed performance testing. I still plan to do that but I need to get this working first :). What's funny is we're both doing this for ZK/Kafka!

Here's my use-case: I am using Vagrant to host Docker and make a "dev env" which simulates multiple data centers by defining private networks:

```ruby
# Vagrantfile
# DC1
config.vm.network "private_network", ip: "192.168.50.2"
# DC2
config.vm.network "private_network", ip: "192.168.60.2"
# DC3
config.vm.network "private_network", ip: "192.168.61.2"
```

Then, I use `iptables` so I can trick maestro into thinking each IP is running docker via:

`iptables -t nat -A OUTPUT -p tcp --dport 4243 -j DNAT --to-destination 10.0.2.15:4243`

Then I define my multiple data centers in formation.yml:

```yml
ships:
dc1:
ip: 192.168.50.2
dc2:
ip: 192.168.60.2
dc3:
ip: 192.168.61.2
```

This setup allows me to effectively simulate a multiple data center Kafka formation. The problem is that maestro binds each container to `0.0.0.0` which means I can only launch a single container. This PR allows the user to specify binding to the ship's IP rather than `0.0.0.0` so that I can circumvent this issue along with not having to do Docker port mapping.

Please let me know what you think. I'm not married to the config option or my implementation and this is my first time ever writing Python. Feel free to rip it apart :)