steeve/boot2docker — pull request #104 by aheissenberger (2014-01-23 21:32:37+00:00)
Title: boot2docker / docker auto mapping port forwarding

Hi

this is my first version - not ready for production!!!

* Implements a wrapper for `docker`
* parses the docker parameter `-p` and `-name`
* will modify port redirection to suport virtual environments
* automatical create dynamical the needed port forwarding rules for virtual box

**Examples:**
```
# setup test
docker pull tutum/apache-php

# Bind TCP port 80 of the container to TCP port 8080 on 127.0.0.1 of the host machine.
./boot2docker cmd docker run -p 127.0.0.1:8080:80 -name webserver tutum/apache-php /run.sh

# Bind TCP port 80 of the container to a dynamically allocated TCP port on 127.0.0.1 of the host machine.
./boot2docker cmd docker run -p 127.0.0.1::80 -name webserver tutum/apache-php /run.sh

# THIS IS THE PREFERED WAY
# Bind TCP port 80 of the container to TCP port 8080 on all available interfaces of the host machine.
./boot2docker cmd docker run -p 8080:80 -name webserver tutum/apache-php /run.sh

# Bind TCP port 80 of the container to a dynamically allocated TCP port on all available interfaces of the host machine.
./boot2docker cmd docker run -p 80 -name webserver tutum/apache-php /run.sh
```

**Requirements:**
* the container needs to be named: -name
* docker will always using dynamical ports inside the VM but the virtual box will forward the defined host port to the dynamic port inside the VM. If you do not define a host port the host port is identical to the dynamical assigned port.

At the moment there is no clean up of the created port forwarding rules except if one rule replaces an existing rule.

This should help to avoid to create not needed port forwarding rules #73 and allows very simple fixed port mapping for development needs #85

looking forward for your feedback