Skip to content

Instantly share code, notes, and snippets.

@rodolfo42
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodolfo42/f0237bd7ecd58445aebc to your computer and use it in GitHub Desktop.
Save rodolfo42/f0237bd7ecd58445aebc to your computer and use it in GitHub Desktop.
Downloads ISO w/ Guest Additions for Virtual Box v4.3.14 and sets up boot2docker to use it
#!/bin/bash
if [ -z $(which boot2docker) ]; then
echo "You must install boot2docker first"
echo "Your PATH: $PATH"
exit 1
fi
if [ -z $(which VBoxManage) ]; then
echo "You must have VBoxManager in your PATH"
echo "Your PATH: $PATH"
exit 1
fi
echo "Stopping current VM..."
boot2docker stop 2> /dev/null
ISO_URL="http://static.dockerfiles.io/boot2docker-v1.2.0-virtualbox-guest-additions-v4.3.14.iso"
ISO_PATH=~/.boot2docker/boot2docker.iso
MD5_ISO=9031696c467eb8a141e208eec8c03632
MD5_LOCAL_ISO=$(md5 -q $ISO_PATH)
if [ "$MD5_ISO" != "MD5_LOCAL_ISO" ]; then
echo "Downloading ISO..."
curl -s -o $ISO_PATH $ISO_URL
else
echo "Skipping ISO download!"
fi
echo "Initializing boot2docker..."
SUCCESS=$(boot2docker init)
if [ "$SUCCESS" != "0" ]; then
echo "Error initializing, destroying VM..."
boot2docker destroy 2> /dev/null
echo "Trying again..."
boot2docker init
fi
SHARED_FOLDERS=$(VBoxManage showvminfo --machinereadable boot2docker-vm | grep SharedFolderNameMachineMapping)
SHARED_HOME_FOLDER=$(echo $SHARED_FOLDERS | grep home)
if [ -z "$SHARED_HOME_FOLDER" ]; then
echo "Linking home folder into VM..."
VBoxManage sharedfolder add boot2docker-vm -name home -hostpath /Users
else
echo "Skipping home folder linkage..."
echo "Linked folders: $SHARED_FOLDERS"
fi
echo "Configuring VM to use 8 GB..."
VBoxManage modifyvm "boot2docker-vm" --memory 8192
echo "Starting VM..."
boot2docker up
@rodolfo42
Copy link
Author

Also maps home directory to the vm, allowing docker run -v ./mydir/:/containerdir/ imagename

@rodolfo42
Copy link
Author

Pre-requisites: boot2docker installed and running, Virtual Box v4.3.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment