Skip to content

Instantly share code, notes, and snippets.

@lalyos
Last active August 29, 2015 13:59
Show Gist options
  • Save lalyos/10537859 to your computer and use it in GitHub Desktop.
Save lalyos/10537859 to your computer and use it in GitHub Desktop.
install specific boot2docker version

The latest version of boot2docker 0.8.0 comes with docker 0.10.0 but we get some strange errors. So if you want to have multiple boot2docker/docker versions parallel you can use this process

boot2docker settings

Boot2docker has 3 parts:

  • boot2docker vm: a VirtualBox vm which is a customized TinyCoreLinux image a bare minimum linux which has docker already installed in it.
  • boot2docker.iso: the boot2docker disk image
  • a shell script: which helps to create/manage the VirtualBox which uses the boot2docker.iso

The boot2docker shell script will create the VirtualBox vm for you with the boot2docker init command. It has some configurable variables:

  • VM_NAME : the name of the vm, it will be displayed in VirtualBox gui
  • DOCKER_PORT : docker server runs inside the vm on port 4243, but it has to be forwarded to the host (your laptop)
  • SSH_HOST_PORT : sometimes you have to ssh into the vm, this is the port the inner 22 is forwarded to
  • VM_MEM : memory used by the VirtualBox vm default is 1024

B2D specific version

if you want to install a specific boot2docker run the following:

curl -Lo /tmp/b2d-version http://j.mp/b2d-version
B2D_RELEASE=v0.7.1 source /tmp/b2d-version

This script will do the following:

  • create a <HOME>/.boot2docker-<VERSION>
  • donwnload the version specifiv boot2docker.iso
  • create <HOME>/.boot2docker-<VERSION>/.profile
  • create a b2d-select alias to choose between boot2docker installations

The profile sets the following ports:

boot2docker version docker version ssh port docker port
0.7.0 0.9.0 2090 4290
0.7.1 0.9.1 2091 4291
0.8.0 0.10.0 2010 4210
: cat <<ENDOFUSAGE
############################################################
curl -Lo /tmp/b2d-version http://j.mp/b2d-version
B2D_RELEASE=v0.7.1 source /tmp/b2d-version
############################################################
Description: https://gist.github.com/lalyos/10537859
############################################################
ENDOFUSAGE
set-ports() {
case $1 in
v0.7.0)
DOCKER_VERSION=0.9.0
SSH_HOST_PORT=2090
DOCKER_PORT=4290
;;
v0.7.1)
DOCKER_VERSION=0.9.1
SSH_HOST_PORT=2091
DOCKER_PORT=4291
;;
v0.8.0)
DOCKER_VERSION=0.10.0
SSH_HOST_PORT=2010
DOCKER_PORT=4210
;;
esac
}
: ${B2D_RELEASE:=v0.7.1}
export BOOT2DOCKER_CFG_DIR=~/.boot2docker-$B2D_RELEASE
BOOT2DOCKER_ISO=$BOOT2DOCKER_CFG_DIR/boot2docker.iso
set-ports $B2D_RELEASE
mkdir -p $BOOT2DOCKER_CFG_DIR
[ -f $BOOT2DOCKER_ISO ] || curl -L -o "$BOOT2DOCKER_ISO" "https://github.com/boot2docker/boot2docker/releases/download/$B2D_RELEASE/boot2docker.iso"
# creates b2d profile
cat >${BOOT2DOCKER_CFG_DIR}/profile <<EOF
VM_NAME=boot2docker-$B2D_RELEASE
VM_MEM=4096
VM_DISK=${BOOT2DOCKER_CFG_DIR}/boot2docker-vm.vmdk
SSH_HOST_PORT=$SSH_HOST_PORT
DOCKER_PORT=$DOCKER_PORT
export DOCKER_HOST=tcp://127.0.0.1:$DOCKER_PORT
EOF
export DOCKER_HOST=tcp://127.0.0.1:$DOCKER_PORT
b2d-select() {
PS3="Enter the number and press <ENTER>: "
echo Which boot2docker to use?
select B2D in ~/.boot2docker*; do
export BOOT2DOCKER_CFG_DIR=$B2D
boot2docker status
break
done
[ -f ${BOOT2DOCKER_CFG_DIR}/profile ] && . ${BOOT2DOCKER_CFG_DIR}/profile
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment