Reputation: 1256
I am trying to create a Docker Swarm with multiple nodes on my Windows 10 PC. According to Docker official documentation, we have to use docker-machine create to create multiple VMs first. I followed the documentation to create the virtual switch "myswitch" and use the following commands:
docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm1
docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm2
created two VMs successfully:
PS C:\Users\richard> docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
myvm1 - hyperv Running tcp://192.168.1.125:2376 v18.09.3
myvm2 - hyperv Running tcp://192.168.1.128:2376 v18.09.3
But when I try to create the third one (3 nodes is good for Swarm cluster), it always fails for some reason:
PS C:\Users\richard> docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm3
Running pre-create checks...
Creating machine...
(myvm3) Copying C:\Users\richard\.docker\machine\cache\boot2docker.iso to C:\Users\rudeng\.docker\machine\machines\myvm3\boot2docker.iso...
(myvm3) Creating SSH key...
(myvm3) Creating VM...
(myvm3) Using switch "myswitch"
(myvm3) Creating VHD
(myvm3) Starting VM...
Error creating machine: Error in driver during machine creation: exit status 1
I have done some research online. One potential cause could be that there is no enough memory so the third VM can't start properly. If we look at the following screenshot from Hyper-V manager on Windows, we can see that the default docker VM takes 2G and each new VM uses 1G by default. My PC has 8G memory, I am not sure how Docker is utilizing the PC resource and how much resource Docker is going to use.
So what I tried was to remove all the VMs created and then create new VM with only 0.5G memory, but it stuck at "waiting for host to start" and failed to create a right VM.
PS C:\Users\richard> docker-machine create -d hyperv --hyperv-memory "512" --hyperv-virtual-switch "myswitch" myvm3
Running pre-create checks...
Creating machine...
(myvm2) Copying C:\Users\richard\.docker\machine\cache\boot2docker.iso to C:\Users\rudeng\.docker\machine\machines\myvm2\boot2docker.iso...
(myvm2) Creating SSH key...
(myvm2) Creating VM...
(myvm2) Using switch "myswitch"
(myvm2) Creating VHD
(myvm2) Starting VM...
(myvm2) Waiting for host to start...
My question is:
Thanks in advance!
Upvotes: 2
Views: 785
Reputation: 142
First I would check that my RAM limits aren't being met.
To do this open command prompt and run the command systeminfo
You will see several lines. The important ones are Total Physical Memory
, and Available Physical Memory
.
If you have 8GB
of ram and 2GB
(this is a guesstimate) is most likely always being used by your machine you'd probably be hitting close to limits with what you have shown in your post of 4GB
usage.
You can also look at your swap space / virtual memory size and see how much is available or in use.
Please report these findings before starting to search in another direction.
More information can be found here.
what's the potential reason for the failure of creating the third VM in this case?
Check your RAM first. As your research has shown this is most likely the case.
And what's the problem of creating a VM with only 0.5G memory?
The same problem you're having currently. The VM doesn't have room to do it's tasks.
What should I do anyway, in this case, to create 3 VMs at least?
Sounds like you might want to increase your RAM. The issue (unless otherwise can be proven) is a physical limitation.
Upvotes: 2