Skip to content
This repository was archived by the owner on Jan 1, 2021. It is now read-only.

boot2docker / docker auto mapping port forwarding#104

Closed
aheissenberger wants to merge 1 commit intoboot2docker:masterfrom
aheissenberger:feature/pull/dynamic-port-forwarding-mapping
Closed

boot2docker / docker auto mapping port forwarding#104
aheissenberger wants to merge 1 commit intoboot2docker:masterfrom
aheissenberger:feature/pull/dynamic-port-forwarding-mapping

Conversation

@aheissenberger
Copy link
Contributor

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

@moul
Copy link
Contributor

moul commented Jan 24, 2014

#93

If using a secondary host only interface, we don't need to update nat rules anymore

@bfirsh
Copy link
Contributor

bfirsh commented Feb 5, 2014

I'm going to give a +1 to #93 and -1 for this. There's no need to wrap the docker command with #93, and it feels far, far less fragile. (What happens on reboot, etc.)

@MichielDeMey
Copy link

I resolved the issue using #93.
We should go with that, it's cleaner and safer to use.

@steeve
Copy link
Contributor

steeve commented Feb 14, 2014

Indeed, closing.

@steeve steeve closed this Feb 14, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants