Skip to content
This repository has been archived by the owner on Feb 27, 2020. It is now read-only.

Commit

Permalink
Remove the dependency on Git bash
Browse files Browse the repository at this point in the history
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: docker-archive#343, docker-archive#335, docker-archive#640, docker-archive#466, docker-archive#687, docker-archive#636.

Signed-off-by: Maxim Plevako <mplevako@gmail.com>
  • Loading branch information
mplevako committed Aug 15, 2018
1 parent 80047f9 commit a2eeca2
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 4 deletions.
4 changes: 2 additions & 2 deletions windows/Toolbox.iss
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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;
Expand Down
101 changes: 99 additions & 2 deletions windows/docker-start.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,100 @@
@echo off
@ECHO OFF

"C:\Program Files\Git\bin\bash.exe" -c " \"/c/Program Files/Docker Toolbox/start.sh\" \"%*\""
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

0 comments on commit a2eeca2

Please sign in to comment.