From c38f3357578bb39b362be554292cad47679dd55f Mon Sep 17 00:00:00 2001 From: Chisomo Sakala Date: Mon, 3 Oct 2016 02:47:24 -0500 Subject: [PATCH 1/3] Add DOCKER_TOOLBOX_INSTALL_PATH to current user's path DOCKER_TOOLBOX_INSTALL_PATH was defined prior, but not added to the users PATH environment variable. Hence commands such as docker, docker-machine, docker-compose do not work unless either they are absolutely qualified or the current directory happens to be %DOCKER_TOOLBOX_INSTALL_PATH% Signed-off-by: Chisomo Sakala --- windows/Toolbox.iss | 1 + 1 file changed, 1 insertion(+) diff --git a/windows/Toolbox.iss b/windows/Toolbox.iss index bd13364e..3443a3a0 100644 --- a/windows/Toolbox.iss +++ b/windows/Toolbox.iss @@ -89,6 +89,7 @@ Type: filesandordirs; Name: "{localappdata}\..\Roaming\Kitematic" [Registry] Root: HKCU; Subkey: "Environment"; ValueType:string; ValueName:"DOCKER_TOOLBOX_INSTALL_PATH"; ValueData:"{app}" ; Flags: preservestringtype uninsdeletevalue; +Root: HKCU; Subkey: "Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}" [Code] #include "base64.iss" From b6aef1227def3a93b9a79d4a27e4c00b7fb873ae Mon Sep 17 00:00:00 2001 From: Chisomo Sakala Date: Mon, 3 Oct 2016 06:46:28 -0500 Subject: [PATCH 2/3] Improved start.sh to make it more robust. -Removed hard coded reference "/c/Program Files/Docker Toolbox" replacing it with $DOCKER_TOOLBOX_INSTALL_PATH -Added quotes around string variables that refer to things such as paths that could potentially have spaces after expansion -Permanently set environment variables DOCKER_HOST, DOCKER_CERT_PATH, DOCKER_MACHINE_NAME, DOCKER_TLS_VERIFY etc using windows SETX instead of the default SET that's provided by `docker-machine env` . Signed-off-by: Chisomo Sakala --- windows/start.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/windows/start.sh b/windows/start.sh index 6332c103..5ba39e66 100644 --- a/windows/start.sh +++ b/windows/start.sh @@ -2,12 +2,21 @@ trap '[ "$?" -eq 0 ] || read -p "Looks like something went wrong in step ´$STEP´... Press any key to continue..."' EXIT -# TODO: I'm sure this is not very robust. But, it is needed for now to ensure -# that binaries provided by Docker Toolbox over-ride binaries provided by +#Quick Hack: used to convert e.g. "C:\Program Files\Docker Toolbox" to "/c/Program Files/Docker Toolbox" +win_to_unix_path(){ + wd="$(pwd)" + cd "$1" + the_path="$(pwd)" + cd "$wd" + echo $the_path +} + +# This is needed to ensure that binaries provided +# by Docker Toolbox over-ride binaries provided by # Docker for Windows when launching using the Quickstart. -export PATH="/c/Program Files/Docker Toolbox:$PATH" +export PATH="$(win_to_unix_path "${DOCKER_TOOLBOX_INSTALL_PATH}"):$PATH" VM=${DOCKER_MACHINE_NAME-default} -DOCKER_MACHINE=./docker-machine.exe +DOCKER_MACHINE="${DOCKER_TOOLBOX_INSTALL_PATH}\docker-machine.exe" STEP="Looking for vboxmanage.exe" if [ ! -z "$VBOX_MSI_INSTALL_PATH" ]; then @@ -61,14 +70,15 @@ if [ $VM_EXISTS_CODE -eq 1 ]; then fi STEP="Checking status on $VM" -VM_STATUS="$( set +e ; ${DOCKER_MACHINE} status ${VM} )" +VM_STATUS="$( set +e ; "${DOCKER_MACHINE}" status "${VM}" )" if [ "${VM_STATUS}" != "Running" ]; then "${DOCKER_MACHINE}" start "${VM}" yes | "${DOCKER_MACHINE}" regenerate-certs "${VM}" fi STEP="Setting env" -eval "$(${DOCKER_MACHINE} env --shell=bash --no-proxy ${VM})" +eval "$("${DOCKER_MACHINE}" env --shell=bash --no-proxy "${VM}" | sed -e "s/export/SETX/g" | sed -e "s/=/ /g")" &> /dev/null #for persistent Environment Variables, available in next sessions +eval "$("${DOCKER_MACHINE}" env --shell=bash --no-proxy "${VM}")" #for transient Environment Variables, available in current session STEP="Finalize" clear @@ -85,10 +95,11 @@ cat << EOF \____\_______/ EOF -echo -e "${BLUE}docker${NC} is configured to use the ${GREEN}${VM}${NC} machine with IP ${GREEN}$(${DOCKER_MACHINE} ip ${VM})${NC}" +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 +echo +#cd #Bad: working dir should be whatever directory was invoked from rather than fixed to the Home folder docker () { MSYS_NO_PATHCONV=1 docker.exe "$@" From 77b43dd39280e17c7d335ee1e6ac7c55f06e9065 Mon Sep 17 00:00:00 2001 From: Chisomo Sakala Date: Mon, 3 Oct 2016 06:56:29 -0500 Subject: [PATCH 3/3] Create "docker-terminal" utility for invoking start.sh from Command Prompt OR Powershell. This plus the more robust start.sh allows docker commands to be invoked from any terminal in Windows. The command docker-terminal can also accept regular docker commands such as - docker-terminal docker ps -a - docker-terminal docker-compose --version Signed-off-by: Chisomo Sakala --- windows/docker-terminal.cmd | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 windows/docker-terminal.cmd diff --git a/windows/docker-terminal.cmd b/windows/docker-terminal.cmd new file mode 100644 index 00000000..3ea5aead --- /dev/null +++ b/windows/docker-terminal.cmd @@ -0,0 +1,3 @@ +@echo off + +"C:\Program Files\Git\bin\bash.exe" -c " \"/c/Program Files/Docker Toolbox/start.sh\" \"%*\"" \ No newline at end of file