Skip to content

Instantly share code, notes, and snippets.

@machielg
Last active November 22, 2018 10:23
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 machielg/6bca4394d26a39cc84bfa51688f42fa0 to your computer and use it in GitHub Desktop.
Save machielg/6bca4394d26a39cc84bfa51688f42fa0 to your computer and use it in GitHub Desktop.
A wrapper shell script to use a virtualbox image for running the docker daemon on MacOS, uses docker-machine
#!/bin/bash
if ! [ -x "$(command -v docker-machine)" ]; then
echo 'docker-machine not installed'
brew install docker-machine
fi
if ! [ -x "$(command -v docker)" ]; then
echo 'docker client not installed'
brew install docker
fi
if ! docker-machine ls -q | grep -q 'vb-box'; then
echo 'creating machine'
docker-machine create -d virtualbox vb-box
echo 'machine created'
fi
if ! docker-machine status vb-box | grep -q 'Running'; then
echo 'starting vb-box'
docker-machine start vb-box
echo 'vb-box started'
fi
eval $(docker-machine env vb-box)
if [ $1 = "halt" ]; then
echo "halting"
docker-machine stop vb-box
else
docker $@
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment