Skip to content

Instantly share code, notes, and snippets.

@smalltown
Last active October 11, 2015 12:52
Show Gist options
  • Save smalltown/d4a135243a2f83a361cb to your computer and use it in GitHub Desktop.
Save smalltown/d4a135243a2f83a361cb to your computer and use it in GitHub Desktop.
This start.sh is for windows "Docker Quick Start"
#!/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
BLUE='\033[1;34m'
GREEN='\033[0;32m'
NC='\033[0m'
if [ ! -f $DOCKER_MACHINE ] || [ ! -f /c/Program\ Files/Oracle/VirtualBox/VBoxManage.exe ]; then
echo "Either VirtualBox or Docker Machine are not installed. Please re-run the Toolbox Installer and try again."
exit 1
fi
/c/Program\ Files/Oracle/VirtualBox/VBoxManage.exe 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 -D 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 $VM --shell bash)"
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
exec "$BASH" --login -i
@smalltown
Copy link
Author

Usage

This start.sh is for windows "Docker Quick Start",
Just replace the file in "C:\Program Files\Docker Toolbox\start.sh"

Who need it ?

  1. For the Windows user wants to use docker-machine from Docker Quick Start

  2. For the Windows user encounters docker-machine env shell problem when trigger Docker Quick Start

    Setting environment variables for machine default...
    Error: Unknown shell

  3. For the Windows user envcounters boot2docker accessibility problem when using Docker Quick Start

    Post http://127.0.0.1:2375/v1.20/containers/create: dial tcp 127.0.0.1:2375: ConnectEx tcp: No connection could be made because the target machine actively refused it..
    * Are you trying to connect to a TLS-enabled daemon without TLS?
    * Is your docker daemon up and running?

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