docker-machine.exe version 0.5.3, build 4d39a66
$ docker-machine env machine01
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.102:2376"
export DOCKER_CERT_PATH="C:\Users\Me\.docker\machine\machines\machine01"
export DOCKER_MACHINE_NAME="machine01"
# Run this command to configure your shell:
# eval "$(C:\Users\Me\bin\docker-machine.exe env machine01)"
The eval uses (Windows) backslash separator but likely should use (Linux) forward slash or escaped-backslash:
$ eval "$(C:\Users\Me\bin\docker-machine.exe env machine01)"
bash: C:UsersMebindocker-machine.exe: command not found
The following work:
eval "$(C:\\Users\\Me\\bin\\docker-machine.exe env machine01)"
eval "$(/C/Users/Me/bin/docker-machine.exe env machine01)"
eval "$(docker-machine.exe env machine01)"
I suggest removing the path from the eval line as well as in the --help
and --version
as it looks different to the other docker tools:
C:\Users\vagrant> docker-machine --version
C:\ProgramData\chocolatey\lib\docker-machine\bin\docker-machine.exe version 0.5.5, build 02c4254
C:\Users\vagrant> docker-compose --version
docker-compose version 1.5.2, build e5cf49d
C:\Users\vagrant> docker --version
Docker version 1.10.0-dev, build 18c9fe0
Point taken. The reason why the full path is used in eval
is to make life easier for us developers with multiple versions of docker-machine
in the path. This is a bad reason since it has a negative impact on real users!
Though, I'd like to point that 0.5.5 fixes the issue on Windows.
eval "$(C:\Users\Me\bin\docker-machine.exe env machine01)"
is replaced by:
eval $("C:\Users\Me\bin\docker-machine.exe" env machine01)
This issue was fixed in https://github.com/docker/machine/pull/2656
The removal of the path to docker-machine in help/version is fixed in https://github.com/docker/machine/pull/2735
@dgageot It seems to me that the quotes are only added if a space is in the filepath. I've just built a docker-machine binary for windows from source and tried it from a Git bash:
$ docker-machine env dev
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://[fe80::215:5dff:fefe:8601]:2376"
export DOCKER_CERT_PATH="C:\Users\vagrant\.docker\machine\machines\dev"
export DOCKER_MACHINE_NAME="dev"
# Run this command to configure your shell:
# eval $(C:\ProgramData\chocolatey\bin\docker-machine.exe env dev)
vagrant@vagrant-2016 MINGW64 /
$ docker-machine --version
docker-machine.exe version 0.6.0-dev, build 03171b8
vagrant@vagrant-2016 MINGW64 /
$
vagrant@vagrant-2016 MINGW64 /
$ eval $(C:\ProgramData\chocolatey\bin\docker-machine.exe env dev)
bash: C:ProgramDatachocolateybindocker-machine.exe: command not found
If I run the same command with quotes, then it works fine:
vagrant@vagrant-2016 MINGW64 /
$ eval $("C:\ProgramData\chocolatey\bin\docker-machine.exe" env dev)
$ echo $DOCKER_HOST
tcp://[fe80::215:5dff:fefe:8601]:2376
I have checked in a plain PowerShell without a space and with a space in the filepath:
C:\Windows\system32> docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
dev - hyperv Running tcp://[fe80::215:5dff:fefe:8601]:2376 v1.9.1
C:\Windows\system32> docker-machine env dev
$Env:DOCKER_TLS_VERIFY = "1"
$Env:DOCKER_HOST = "tcp://[fe80::215:5dff:fefe:8601]:2376"
$Env:DOCKER_CERT_PATH = "C:\Users\vagrant\.docker\machine\machines\dev"
$Env:DOCKER_MACHINE_NAME = "dev"
# Run this command to configure your shell:
# & C:\ProgramData\chocolatey\bin\docker-machine.exe env dev | Invoke-Expression
C:\Windows\system32> docker-machine --version
docker-machine.exe version 0.6.0-dev, build 03171b8
C:\Windows\system32> mkdir 'C:\Program Files\docker'
Directory: C:\Program Files
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 04.01.2016 18:06 docker
C:\Windows\system32> copy C:\ProgramData\chocolatey\bin\docker-machine.exe 'C:\Program Files\docker\'
C:\Windows\system32> $env:PATH="C:\Program Files\docker\;$env:PATH"
C:\Windows\system32> docker-machine env dev
$Env:DOCKER_TLS_VERIFY = "1"
$Env:DOCKER_HOST = "tcp://[fe80::215:5dff:fefe:8601]:2376"
$Env:DOCKER_CERT_PATH = "C:\Users\vagrant\.docker\machine\machines\dev"
$Env:DOCKER_MACHINE_NAME = "dev"
# Run this command to configure your shell:
# & "C:\Program Files\docker\docker-machine.exe" env dev | Invoke-Expression
And now I also compared it in the Git bash:
$ export PATH="/c/Program Files/docker:/c/Users/vagrant/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/vagrant/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/ProgramData/chocolatey/bin:/c/Users/vagrant/AppData/Local/atom/bin:/usr/bin/vendor_perl:/usr/bin/core_perl"
vagrant@vagrant-2016 MINGW64 /
$ docker-machine env dev
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://[fe80::215:5dff:fefe:8601]:2376"
export DOCKER_CERT_PATH="C:\Users\vagrant\.docker\machine\machines\dev"
export DOCKER_MACHINE_NAME="dev"
# Run this command to configure your shell:
# eval $("C:\Program Files\docker\docker-machine.exe" env dev)
So the backslashes make trouble in a Git bash without the quotes.
@StefanScherer You are right. Let's keep this ticket opened then...
docker-machine.exe version 0.8.2, build e18a919
I created tow machine with docker-machine.exe on Windows 10, but i removed the default one:
$ docker-machine rm default
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
ape - virtualbox Running tcp://192.168.99.101:2376 v1.12.5
then,
$ docker-machine.exe active
No active host found
i try to use this way to solve it:
# For cmd.exe:
$ docker-machine.exe env --shell cmd dev
set DOCKER_TLS_VERIFY=1
set DOCKER_HOST=tcp://192.168.99.101:2376
set DOCKER_CERT_PATH=C:\Users\captain\.docker\machine\machines\dev
set DOCKER_MACHINE_NAME=dev
# Run this command to configure your shell: copy and paste the above values into your command prompt
the set
command is not invalid, What may be the reason for it?
@FreeApe In which terminal/shell are you calling docker-machine.exe env ...
?
If you explicitly add --shell cmd
then you want the CMD type output and that uses the cmd.exe set XXX=YYY
syntax.
What happens if you just run docker-machine.exe env dev
? It should find the right syntax automatically for your shell (introduced with eg. https://github.com/docker/machine/pull/2821).
also please update your docs:
https://docs.docker.com/get-started/part4/#configure-a-docker-machine-shell-to-the-swarm-manager
above its shown as to run below command on windows
& "C:\Program Files\Docker\Docker\Resources\bindocker-machine.exe" env myvm1 | Invoke-Expression
but the command should have been as
eval $("C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe" env myvm1)
@MateenKhan it depends in which shell you call the docker-machine binary. The docs show a PowerShell (ok, this could be added to the docs) and for that the command is correct.
In which shell do you have called the docker-machine binary?