Docker Toolbox for Windows is nice toolbox, make docker dev/test possible on windows and Mac OSX.
It includes:
- docker-machine to create and operate docker machine which is linux vm within virtualbox, vmware, aws ec2
- docker client to run docker command outside vm docker server
The main benefit to run docker client for me, it is easy to integrate docker return result with local win docker control host.
start docker machine
This is how to start docker machine manually:
$ docker-machine start cygdemo $ docker-machine env cygdemo $ docker-machine status cygdemo running $ docker-machine ip cygdemo 10.0.10.100
connection error
however you will hit issue with docker client connection error like this:
$ docker ps -a An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json?all=1: open //./pipe/docker_engine: The system cannot find the file specified. $ docker info An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/info: open //./pipe/docker_engine: The system cannot find the file specified.
You verify docker-machine ssh is working but cannot ping to docker server vm ip.
troubleshooting
If you search from Internet, there are huge amount of misleading info for this, will suggest to remove Host-Only network driver from virtualbox, reinstall docker toolbox, finally I found out the real cause for my case.
$ docker-machine env cygdemo export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://10.0.10.100:2376" export DOCKER_CERT_PATH="C:\Users\\.docker\machine\machines\cygdemo" export DOCKER_MACHINE_NAME="cygdemo" # Run this command to configure your shell: # eval $("L:\portabledevops\cygwin64\usr\local\bin\docker-machine.exe" env cygdemo)
docker-machine env only display instead of run the env command!
$ docker-machine env --help Usage: docker-machine env [OPTIONS] [arg...] Display the commands to set up the environment for the Docker client
dm env setup
The correct way is using eval:
eval $(docker-machine env cygdemo) you can verify exported env: $ env|grep DOCKER DOCKER_HOST=tcp://10.0.10.100:2376 DOCKER_MACHINE_NAME=cygdemo DOCKER_TLS_VERIFY=1 DOCKER_CERT_PATH=C:\Users\\.docker\machine\machines\cygdemo $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
denv function
I use script function to simply this work:
alias dm=/usr/local/bin/docker-machine.exe denv(){ eval $(docker-machine env "$@") } export -f denv
you can enable env like this:
$ denv cygdemo verify by $ dm ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS cygdemo * virtualbox Running tcp://10.0.10.100:2376 v1.12.3 * means cygdemo is active docker machine $ docker info denv only supports one machine, 0 or 2+ will get error as below: $ denv Error: No machine name(s) specified and no "default" machine exists. $ denv a b Error: Expected one machine name as an argument