#!/bin/bash VM=default DOCKER_MACHINE=`which docker-machine` #### ## Step 1 : Start Docker #### 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" ] || [ ! -f "${VBOXMANAGE}" ]; then echo "Either VirtualBox or Docker Machine are not installed. Please re-run the Toolbox Installer and try again." exit 1 fi "${VBOXMANAGE}" showvminfo $VM &> /dev/null VM_EXISTS_CODE=$? set -e if [ $VM_EXISTS_CODE -eq 1 ]; then echo "Creating Machine $VM..." "$DOCKER_MACHINE" rm -f $VM &> /dev/null || : rm -rf ~/.docker/machine/machines/$VM "$DOCKER_MACHINE" create -d virtualbox --virtualbox-memory 2048 $VM else echo "Machine $VM already exists in VirtualBox." fi echo "Starting machine $VM..." "$DOCKER_MACHINE" start $VM echo "Setting environment variables for machine $VM..." eval "$($DOCKER_MACHINE env --shell=bash $VM)" echo -e "${BLUE}docker${NC} is configured to use the ${GREEN}$VM${NC} machine with IP ${GREEN}$($DOCKER_MACHINE ip $VM)${NC}" #### ## Step 2 : Add certificat #### "$DOCKER_MACHINE" ssh $VM << EOF sudo mkdir -p /etc/docker/certs.d/docker.wcentric.com/ sudo wget -O /etc/docker/certs.d/docker.wcentric.com/ca.crt http://docker.wcentric.com/ca.crt EOF #### ## Step 3 : Regenerate certificats #### "$DOCKER_MACHINE" regenerate-certs --force $VM echo "Everything is OK" echo "Press any key to quit...." read -n1