Last active
August 29, 2015 14:18
-
-
Save cmbaughman/f969337ae2756ff850ed to your computer and use it in GitHub Desktop.
Forward all of Docker’s ports from the VM to localhost. (Boot2Docker)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| # Check for nsenter. If not found, install it | |
| boot2docker ssh '[ -f /var/lib/boot2docker/nsenter ] || docker run --rm -v /var/lib/boot2docker/:/target jpetazzo/nsenter' | |
| # Use bash if no command is specified | |
| args=$@ | |
| if [[ $# = 1 ]]; then | |
| args+=(/bin/bash) | |
| fi | |
| boot2docker ssh -t sudo /var/lib/boot2docker/docker-enter "${args[@]}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Forward all of Docker’s ports from the VM to localhost. | |
| # vm must be powered off | |
| for i in {49000..49900}; do | |
| VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i"; | |
| VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i"; | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment