Skip to content

Instantly share code, notes, and snippets.

@cmbaughman
Last active August 29, 2015 14:18
Show Gist options
  • Select an option

  • Save cmbaughman/f969337ae2756ff850ed to your computer and use it in GitHub Desktop.

Select an option

Save cmbaughman/f969337ae2756ff850ed to your computer and use it in GitHub Desktop.
Forward all of Docker’s ports from the VM to localhost. (Boot2Docker)
#!/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[@]}"
#!/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