$ docker-machine env default export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.99.100:2376" export DOCKER_CERT_PATH="/Users/yibo/.docker/machine/machines/default" export DOCKER_MACHINE_NAME="default" # Run this command to configure your shell: # eval "$(docker-machine env default)"
p.s. 如果是用docker-machine create命令从 terminal 创建 VM 的话,是会提示你设置环境变量的
1 2 3 4 5 6 7 8 9 10 11
$ docker-machine create --driver virtualbox test Running pre-create checks... Creating machine... Waiting for machine to be running, this may take a few minutes... Machine is running, waiting for SSH to be available... Detecting operating system of created instance... Provisioning created instance... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... To see how to connect Docker to this machine, run: docker-machine envtest
注:这里的/home/docker/datadir是 VM 中的文件目录,删除 container 的不会自动删除该文件目录,需要进入 VM 以 ROOT 权限手动删除。曾经在 Windows 上刚开始使用 Docker 的时候,在这个问题上边纠结了好久,就因为我只顾 docker 玩的嗨,忘了中间这个虚拟机。附图一张: