Skip to content

Instantly share code, notes, and snippets.

@tdomzal
Last active December 9, 2015 10:46
Show Gist options
  • Save tdomzal/ed750cdd971438184642 to your computer and use it in GitHub Desktop.
Save tdomzal/ed750cdd971438184642 to your computer and use it in GitHub Desktop.
Windows cmd shell for updating docker variables with option to set on system level.
@ECHO OFF
setlocal EnableDelayedExpansion
if "%1"=="/s" (
set system=true
shift /1
)
:execute
if "%1"=="" goto usage
FOR /f "tokens=*" %%i IN ('docker-machine env --shell cmd %1') DO %%i
if "%system%"=="true" (
echo Setting system variables:
echo DOCKER_TLS_VERIFY="%DOCKER_TLS_VERIFY%"
echo DOCKER_HOST="%DOCKER_HOST%"
echo DOCKER_CERT_PATH="%DOCKER_CERT_PATH%"
echo DOCKER_MACHINE_NAME="%DOCKER_MACHINE_NAME%"
@setx DOCKER_TLS_VERIFY "%DOCKER_TLS_VERIFY%"
@setx DOCKER_HOST "%DOCKER_HOST%"
@setx DOCKER_CERT_PATH "%DOCKER_CERT_PATH%"
@setx DOCKER_MACHINE_NAME "%DOCKER_MACHINE_NAME%"
)
goto end
:usage
echo Update docker variables in windows CMD shell.
echo.
echo Usage
echo %0 [ /s ] ^<machine_id^>
echo.
echo Where:
echo /s
echo set variables in current user system environment
echo ^<machine_id^>
echo registered docker machine
echo.
echo Please note that redefining system variables
echo requires reloading of actual process to make effect.
echo.
echo To check list of registered docker machines execute:
echo docker-machine ls
echo.
exit /b 1
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment