Skip to content

Instantly share code, notes, and snippets.

@jessedearing
Last active August 29, 2015 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jessedearing/10406245 to your computer and use it in GitHub Desktop.
Save jessedearing/10406245 to your computer and use it in GitHub Desktop.
My boot2docker init adding port forwarding for all the cool services I use
#!/usr/bin/env sh
if ! which boot2docker; then
brew install boot2docker
mkdir $HOME/.boot2docker
echo DOCKER_PORT=32000 > $HOME/.boot2docker/profile
fi
if [[ -z $DOCKER_HOST ]]; then
export DOCKER_HOST="tcp://127.0.0.1:32000"
add_to_shell=1
fi
if boot2docker status | grep "does not exist"; then
boot2docker init
elif boot2docker status; then
echo "boot2docker already started; please stop before running"
exit 1
fi
function add_boot2docker_port() {
VBoxManage controlvm "boot2docker-vm" --natpf1 "tcp-port$1,tcp,127.0.0.1,$1,,$1";
VBoxManage controlvm "boot2docker-vm" --natpf1 "udp-port$1,udp,127.0.0.1,$1,,$1";
}
VBoxManage modifyvm "boot2docker-vm" --cpus $(sysctl -n hw.ncpu)
VBoxManage modifyvm "boot2docker-vm" --memory "$(echo $(sysctl -n hw.memsize)/1024/1024*0.66/1 | bc)"
boot2docker start
# Nginx (HTTP)
add_boot2docker_port 8080
# Nginx (HTTPS)
add_boot2docker_port 4343
# Etcd
add_boot2docker_port 4001
# MySQL
# add_boot2docker_port 3306
echo "Please set the variable: DOCKER_HOST=tcp://127.0.0.1:32000 in your shell's .profile or .${SHELL##*/}rc file."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment