Search code examples
dockerdocker-for-windowsdocker-desktop

Change Docker for windows to use another VM besides MobylinuxVM


Setup Docker Desktop for Windows.

Created a new VM Create a Docker Machine ....

docker-machine create -d hyperv --hyperv-virtual-switch "External" manager11

Ran through all the tutorials on this machine and everything is working

https://docs.docker.com/docker-for-windows/

Now I would like to change my Local Docker client to use this newly created machine instead of the MobylinuxVM.


Solution

  • docker-machine env can output the environment for cmd or powershell. The output includes comments with the command to set the environment in your shell.

    CMD

    C:\> docker-machine env --shell cmd manager11
    SET DOCKER_TLS_VERIFY=1
    SET DOCKER_HOST=tcp://192.168.99.100:2376
    SET DOCKER_CERT_PATH=C:/Users/matt/.docker/machine/machines/manager11
    SET DOCKER_MACHINE_NAME=manager11
    REM Run this command to configure your shell: 
    REM     @FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd manager11') DO @%i
    

    Powershell

    PS C:\> docker-machine env --shell powershell manager11
    $Env:DOCKER_TLS_VERIFY = "1"
    $Env:DOCKER_HOST = "tcp://192.168.99.100:2376"
    $Env:DOCKER_CERT_PATH = "C:/Users/matt/.docker/machine/machines/manager11"
    $Env:DOCKER_MACHINE_NAME = "manager11"
    # Run this command to configure your shell: 
    # & docker-machine env --shell powershell manager11 | Invoke-Expression