From a2eeca24fed7137106148dfaefe7976d968dea6f Mon Sep 17 00:00:00 2001 From: Maxim Plevako Date: Mon, 13 Aug 2018 23:38:48 +0300 Subject: [PATCH] Remove the dependency on Git bash Different Git packages use different installation paths, which, in their turn may also be redefined by the user. Moreover, even if Git is installed there is no guarantee that the Bash component is also present. So there is little sense to depend on Git bash or to consider it to be at any specific location. Resolves: #343, #335, #640, #466, #687, #636. Signed-off-by: Maxim Plevako --- windows/Toolbox.iss | 4 +- windows/docker-start.cmd | 101 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 4 deletions(-) diff --git a/windows/Toolbox.iss b/windows/Toolbox.iss index cac6c0f9..52fba88d 100644 --- a/windows/Toolbox.iss +++ b/windows/Toolbox.iss @@ -79,7 +79,7 @@ Source: "{#virtualBoxMsi}"; DestDir: "{app}\installers\virtualbox"; DestName: "v [Icons] Name: "{userprograms}\Docker\Kitematic (Alpha)"; WorkingDir: "{app}"; Filename: "{app}\kitematic\Kitematic.exe"; Components: "Kitematic" Name: "{commondesktop}\Kitematic (Alpha)"; WorkingDir: "{app}"; Filename: "{app}\kitematic\Kitematic.exe"; Tasks: desktopicon; Components: "Kitematic" -Name: "{userprograms}\Docker\Docker Quickstart Terminal"; WorkingDir: "{app}"; Filename: "{pf64}\Git\bin\bash.exe"; Parameters: "--login -i ""{app}\start.sh"""; IconFilename: "{app}/docker-quickstart-terminal.ico"; Components: "Docker" +Name: "{userprograms}\Docker\Docker Quickstart Terminal"; WorkingDir: "{app}"; Filename: "{app}\docker-start.cmd"; IconFilename: "{app}/docker-quickstart-terminal.ico"; Components: "Docker" Name: "{commondesktop}\Docker Quickstart Terminal"; WorkingDir: "{app}"; Filename: "{pf64}\Git\bin\bash.exe"; Parameters: "--login -i ""{app}\start.sh"""; IconFilename: "{app}/docker-quickstart-terminal.ico"; Tasks: desktopicon; Components: "Docker" [UninstallRun] @@ -191,7 +191,7 @@ end; function NeedToInstallGit(): Boolean; begin // TODO: Find a better way to see if Git is installed - Result := not DirExists('C:\Program Files\Git') or not FileExists('C:\Program Files\Git\git-bash.exe') + Result := not DirExists('C:\Program Files\Git') end; procedure InitializeWizard; diff --git a/windows/docker-start.cmd b/windows/docker-start.cmd index 3ea5aead..f87e5032 100644 --- a/windows/docker-start.cmd +++ b/windows/docker-start.cmd @@ -1,3 +1,100 @@ -@echo off +@ECHO OFF -"C:\Program Files\Git\bin\bash.exe" -c " \"/c/Program Files/Docker Toolbox/start.sh\" \"%*\"" \ No newline at end of file +REM This is needed to ensure that binaries provided +REM by Docker Toolbox over-ride binaries provided by +REM Docker for Windows when launching using the Quickstart. +SET PATH=%DOCKER_TOOLBOX_INSTALL_PATH%;%PATH% +IF DEFINED DOCKER_MACHINE_NAME ( + SET VM=%DOCKER_MACHINE_NAME% +) ELSE SET VM=default +SET DOCKER_MACHINE=%DOCKER_TOOLBOX_INSTALL_PATH%\docker-machine.exe +SET VM_DIR=%HOMEDRIVE%%HOMEPATH%\.docker\machine\machines\%VM% + +SET STEP=Looking for vboxmanage.exe +IF DEFINED VBOX_MSI_INSTALL_PATH ( + SET VBOXMANAGE=%VBOX_MSI_INSTALL_PATH%VBoxManage.exe +) ELSE SET VBOXMANAGE=%VBOX_INSTALL_PATH%VBoxManage.exe + +REM clear all_proxy if not socks address +IF DEFINED ALL_PROXY IF %ALL_PROXY:~0:5% NEQ socks SET ALL_PROXY + +IF NOT EXIST "%DOCKER_MACHINE%" ( + ECHO "Docker Machine is not installed. Please re-run the Toolbox Installer and try again." + EXIT /B 1 +) + +IF NOT EXIST "%VBOXMANAGE%" ( + ECHO "VirtualBox is not installed. Please re-run the Toolbox Installer and try again." + EXIT /B 1 +) + +IF DEFINED VM_ITEM SET VM_ITEM +ECHO Looking if %VM% already exists... +(FOR /F "delims=" %%V IN ('""%VBOXMANAGE%" list vms | findstr "%VM%""') DO SET VM_ITEM=%%V) || EXIT /B 1 + +SET STEP=Checking if machine %VM% exists +IF NOT DEFINED VM_ITEM ( + "%DOCKER_MACHINE%" rm -f "%VM%" > NUL 2>&1 || CALL :reportError + IF EXIST "%VM_DIR%" RMDIR /S /Q "%VM_DIR%" || CALL :reportError + REM set proxy variables inside virtual docker machine if they exist in host environment + IF DEFINED HTTP_PROXY SET PROXY_ENV=%PROXY_ENV% --engine-env HTTP_PROXY=%HTTP_PROXY% + IF DEFINED HTTPS_PROXY SET PROXY_ENV=%PROXY_ENV% --engine-env HTTPS_PROXY=%HTTPS_PROXY% + IF DEFINED NO_PROXY SET PROXY_ENV=%PROXY_ENV --engine-env NO_PROXY=%NO_PROXY% + "%DOCKER_MACHINE%" create -d virtualbox %PROXY_ENV% "%VM%" || CALL :reportError +) + +SET STEP=Checking status of %VM% +ECHO Checking status of %VM%... +(FOR /F %%V IN ('""%DOCKER_MACHINE%" status "%VM%""') DO SET VM_STATUS=%%V) || EXIT /B 1 +IF ERRORLEVEL 0 IF "%VM_STATUS: =%" NEQ "Running" ( + "%DOCKER_MACHINE%" start "%VM%" || CALL :reportError + ECHO y | "%DOCKER_MACHINE%" regenerate-certs "%VM%" || CALL :reportError +) + +SET STEP=Setting env +REM for persistent environment variables, available in next sessions +ECHO Setting persistent environment variables, available in next sessions... +(FOR /F eol^=#^ tokens^=2^,3^ delims^=^"^=^ %%V IN ('""%DOCKER_MACHINE%" env --shell=bash --no-proxy "%VM%""') DO ( + (SETX %%V %%W) > NUL 2>&1 +)) || EXIT /B 1 +REM EXIT /B 1 +REM for transient environment variables, available in current session +ECHO Setting transient environment variables, available in current session... +(FOR /F eol^=#^ tokens^=2^,3^ delims^=^"^=^ %%V IN ('""%DOCKER_MACHINE%" env --shell=bash --no-proxy "%VM%""') DO (SET %%V=%%W +)) || EXIT /B 1 + +SET STEP=Finalize +ECHO Determining the %VM%'s IP... +(FOR /F %%V IN ('""%DOCKER_MACHINE%" ip "%VM%""') DO SET IP=%%V) || EXIT /B 1 +CLS +ECHO. +ECHO. +ECHO ## . +ECHO ## ## ## == +ECHO ## ## ## ## ## === +ECHO /"""""""""""""""""\___/ === +ECHO ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~ +ECHO \______ o __/ +ECHO \ \ __/ +ECHO \____\_______/ +ECHO. + +ECHO docker is configured to use the %VM% machine with IP %IP% +ECHO For help getting started, check out the docs at https://docs.docker.com +ECHO. +ECHO. + +IF "%1"=="" ( + ECHO Start interactive shell + CMD +) ELSE ( + ECHO Start shell with command + CMD /K docker %* +) + +GOTO:EOF + +:reportError +ECHO Looks like something went wrong in step `%STEP%`... Press any key to continue... +PAUSE > NUL +GOTO:EOF \ No newline at end of file