- 现象
win10下,使用docker-machine命令创建一组虚拟机,然后查看创建的虚拟机。结果报错:Unable to query docker version: Get https://10.168.38.182:2376/v1.15/version: x509: certificate is valid for 127.0.0.1, not 10.168.38.182
docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm1
docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm2
docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
myvm1 - hyperv Running tcp://10.168.38.182:2376 Unknown Unable to query docker version: Get https://10.168.38.182:2376/v1.15/version: x509: certificate is valid for 127.0.0.1, not 10.168.38.182
myvm2 - hyperv Running tcp://10.168.38.181:2376 Unknown Unable to query docker version: Get https://10.168.38.181:2376/v1.15/version: x509: certificate is valid for 127.0.0.1, not 10.168.38.181
- 解决方案
使用'docker-machine regenerate-certs [name]'命令为虚拟机重新生成证书。
docker-machine regenerate-certs -f myvm1
docker-machine regenerate-certs -f myvm1
- 最后
重新为虚拟机生成证书以后,可以正常查看虚拟机信息。
docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER
myvm1 - hyperv Running tcp://10.168.38.182:2376 v17.09.0-ce
myvm2 - hyperv Running tcp://10.168.38.181:2376 v17.09.0-ce