先讲解一下如何创建一个machine
1. 打开命令行
2. 使用 docker-machine ls
命令,默认情况下如下
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
3. 创建一个machine
- 如果你使用mac,不支持Hyper-V的windows上使用toolbox或者是docker for mac 需要使用virtualbox作为驱动。
- 如果使用docker for windows可以使用如下方式创建
选择一个machine之后,选择虚拟机交换管理器
之后创建外部网络
点击确定
这样就可以创建machine了
docker-machine create -d hyperv --hyperv-virtual-switch "<NameOfVirtualSwitch>" <nameOfNode>
下面是示例:
```shell
PS C:\WINDOWS\system32> docker-machine create -d hyperv --hyperv-virtual-switch "Primary Virtual Switch" default
Running pre-create checks...
Creating machine...
(manager1) Copying C:\Users\Vicky\.docker\machine\cache\boot2docker.iso to C:\Users\Vicky\.docker\machine\machines\manag
er1\boot2docker.iso...
(manager1) Creating SSH key...
(manager1) Creating VM...
(manager1) Using switch "Primary Virtual Switch"
(manager1) Creating VHD
(manager1) Starting VM...
(manager1) Waiting for host to start...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: C:\Program Files\Doc
ker\Docker\Resources\bin\docker-machine.exe env manager1
PS C:\WINDOWS\system32>
```
但是笔者电脑出现了一个
Error creating machine: Error in driver during machine creation: exit status 1
经过几次尝试怀疑为内存不足,通过更改最小启动内存解决问题。
C:\WINDOWS\system32>docker-machine create -d hyperv --hyperv-virtual-switch "primary Virtual switch" default
Running pre-create checks...
(default) Image cache directory does not exist, creating it at C:\Users\LiangWentao\.docker\machine\cache...
(default) No default Boot2Docker ISO found locally, downloading the latest release...
(default) Latest release for github.com/boot2docker/boot2docker is v1.12.3
(default) Downloading C:\Users\LiangWentao\.docker\machine\cache\boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v1.12.3/boot2docker.iso...
(default) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(default) Copying C:\Users\LiangWentao\.docker\machine\cache\boot2docker.iso to C:\Users\LiangWentao\.docker\machine\machines\default\boot2docker.iso...
(default) Creating SSH key...
(default) Creating VM...
(default) Using switch "primary Virtual switch"
(default) Creating VHD
(default) Starting VM...
Error creating machine: Error in driver during machine creation: exit status 1