Created
March 21, 2016 15:29
-
-
Save IanHopkinson/85453a90212eb6627f29 to your computer and use it in GitHub Desktop.
Modified start.sh for Docker Toolbox.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
trap '[ "$?" -eq 0 ] || read -p "Looks like something went wrong... Press any key to continue..."' EXIT | |
VM=default | |
#DOCKER_MACHINE=./docker-machine.exe | |
DOCKER_MACHINE=/c/Program\ Files/Docker\ Toolbox/docker-machine.exe | |
if [ ! -z "$VBOX_MSI_INSTALL_PATH" ]; then | |
VBOXMANAGE="${VBOX_MSI_INSTALL_PATH}VBoxManage.exe" | |
else | |
VBOXMANAGE="${VBOX_INSTALL_PATH}VBoxManage.exe" | |
fi | |
BLUE='\033[1;34m' | |
GREEN='\033[0;32m' | |
NC='\033[0m' | |
if [ ! -f "${DOCKER_MACHINE}" ]; then | |
echo "Docker Machine is not installed. Please re-run the Toolbox Installer and try again." | |
exit 1 | |
fi | |
if [ ! -f "${VBOXMANAGE}" ]; then | |
echo "VirtualBox is not installed. Please re-run the Toolbox Installer and try again." | |
exit 1 | |
fi | |
"${VBOXMANAGE}" list vms | grep \""${VM}"\" &> /dev/null | |
VM_EXISTS_CODE=$? | |
set -e | |
echo "Creating vm" | |
if [ $VM_EXISTS_CODE -eq 1 ]; then | |
"${DOCKER_MACHINE}" rm -f "${VM}" &> /dev/null || : | |
rm -rf ~/.docker/machine/machines/"${VM}" | |
"${DOCKER_MACHINE}" create -d virtualbox "${VM}" | |
fi | |
echo "Getting vm status" | |
VM_STATUS=$("${DOCKER_MACHINE}" status ${VM} 2>&1) | |
echo ${VM_STATUS} | |
echo "About to regenerate certificates" | |
if [ "${VM_STATUS}" != "Running" ]; then | |
"${DOCKER_MACHINE}" start "${VM}" | |
yes | "${DOCKER_MACHINE}" regenerate-certs "${VM}" | |
fi | |
echo "Running env" | |
eval $("${DOCKER_MACHINE}" env --shell=bash ${VM}) | |
#clear | |
cat << EOF | |
## . | |
## ## ## == | |
## ## ## ## ## === | |
/"""""""""""""""""\___/ === | |
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~ | |
\______ o __/ | |
\ \ __/ | |
\____\_______/ | |
EOF | |
echo -e ${BLUE}docker${NC} is configured to use the ${GREEN}${VM}${NC} machine with IP ${GREEN}$("${DOCKER_MACHINE}" ip ${VM})${NC} | |
echo "For help getting started, check out the docs at https://docs.docker.com" | |
echo | |
cd | |
docker () { | |
MSYS_NO_PATHCONV=1 docker.exe "$@" | |
} | |
export -f docker | |
exec "${BASH}" --login -i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment