Skip to content

Instantly share code, notes, and snippets.

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

  • Save JasonGiedymin/10f95c2dc5aaeac1fa80 to your computer and use it in GitHub Desktop.

Select an option

Save JasonGiedymin/10f95c2dc5aaeac1fa80 to your computer and use it in GitHub Desktop.
Simple script to help drive the boot2docker docker with parallels without much change.
#!/bin/bash
# Author: Jason Giedymin <jason dot giedymin -at- gmail dot com>
# License: Apache2
# Desc: Simple script to help drive the boot2docker docker with
# parallels without much change.
set -e
BOOT2DOCKER_PARALLELS=~/boot2docker-parallels
function install() {
cat <<EOF
------------------------------------------------------------
# Consider these instructions to allow this script to work
vagrant plugin install vagrant-parallels
cd ~ # or where you want to clone the boot2docker parallels box
mkdir ~/boot2docker-parallels
pushd ~/boot2docker-parallels
vagrant init parallels/boot2docker
vagrant up
vagrant ssh -c "sudo sh -c 'echo \"export DOCKER_TLS=no\" > /var/lib/boot2docker/profile'"
vagrant reload
vagrant halt
popd
# re-run this tool
$0 up
------------------------------------------------------------
EOF
}
function pre() {
echo "Preparing boot2docker parallels vm..."
pushd $BOOT2DOCKER_PARALLELS
}
function post() {
popd
}
function setEnv() {
unset DOCKER_TLS_VERIFY
export DOCKER_HOST="tcp://`vagrant ssh-config | sed -n "s/[ ]*HostName[ ]*//gp"`:2375"
}
function manualEnv() {
echo
echo "Please set the following in the current shell:"
echo " unset DOCKER_TLS_VERIFY"
echo " export DOCKER_HOST=$DOCKER_HOST"
echo
}
function dockerTest() {
sleep 2
time docker version
time docker ps
echo "Complete."
echo "See https://github.com/Parallels/boot2docker-vagrant-box for instructions if errors occur."
}
function env() {
pre
setEnv
dockerTest
post
}
function status() {
pre
vagrant status
post
}
function up() {
pre
vagrant up
setEnv
dockerTest
post
}
function down() {
pre
vagrant halt
post
}
function destroy() {
pre
echo "Press any key to continue with destroy..."
read
post
}
function usage() {
cat <<EOF
$0 {up|down|halt|destroy|usage|env|install|status}
EOF
}
case "$1" in
up)
time up
;;
down|halt)
time down
;;
destroy)
destroy
;;
usage)
usage
;;
env)
env
manualEnv
;;
status)
status
;;
install)
install
;;
*)
echo "Command '$1' unknown."
usage
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment