Skip to content

Instantly share code, notes, and snippets.

@augi
Last active January 15, 2016 20:57
Show Gist options
  • Save augi/477a120f9f5a3d435898 to your computer and use it in GitHub Desktop.
Save augi/477a120f9f5a3d435898 to your computer and use it in GitHub Desktop.
Script to be executed after Windows starts, requires Docker Toolbox installed.
@ECHO OFF
SET VM_NAME=default
SET MOUNT_SRC=E:\Work
SET MOUNT_DST=/e/work
SET MOUNT_NAME=work
ECHO Creating VirtualBox machine '%VM_NAME%'...
docker-machine create --driver virtualbox --virtualbox-host-dns-resolver %VM_NAME%
REM Stop is required because shared folder can be added to stopped machine only
ECHO Stopping VirtualBox machine '%VM_NAME%'...
docker-machine stop %VM_NAME%
ECHO Adding shared folder '%MOUNT_NAME%' to VBox (mapped from '%MOUNT_SRC%')
"%VBOX_MSI_INSTALL_PATH%/vboxmanage" sharedfolder add %VM_NAME% --name %MOUNT_NAME% --hostpath "%MOUNT_SRC%"
ECHO Starting VirtualBox machine...
docker-machine start %VM_NAME%
ECHO Mounting shared folder '%MOUNT_NAME%' to '%MOUNT_DST%'
docker-machine ssh %VM_NAME% "sudo mkdir %MOUNT_DST% && sudo mount -t vboxsf %MOUNT_NAME% %MOUNT_DST%"
ECHO Configuring environment variables
FOR /f "tokens=*" %%i IN ('docker-machine env --shell cmd %VM_NAME%') DO %%i
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%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment