docker machine报错x509

docker machine报错x509

实验环境

操作系统:CentOS Linux release 7.3.1611 (Core)

docker版本:17.11.0-ce

docker-machine版本:0.13.0

问题还原

启动已存在的docker-machine default:

[root@localhost ~]# docker-machine start default
Starting "default"...
(default) Check network to re-create if needed...
(default) Waiting for an IP...
Machine "default" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.

查看docker-machine列表报错:
Unable to query docker version: Get https://192.168.99.100:2376/v1.15/version: x509: certificate is valid for 127.0.0.1, 10.0.2.15, 192.168.99.102, not 192.168.99.100

[root@localhost ~]# docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
default   -        virtualbox   Running   tcp://192.168.99.100:2376           Unknown   Unable to query docker version: Get https://192.168.99.100:2376/v1.15/version: x509: certificate is valid for 127.0.0.1, 10.0.2.15, 192.168.99.102, not 192.168.99.100
myvm1     -        virtualbox   Stopped                                       Unknown   
myvm2     -        virtualbox   Stopped                                       Unknown   

根据错误信息判断是网络配置问题,查看其env发现报同样错误,并给出提示解决方案:

[root@localhost ~]# docker-machine env default
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376": x509: certificate is valid for 127.0.0.1, 10.0.2.15, 192.168.99.102, not 192.168.99.100
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which might stop running containers.

根据提示对default执行回收操作:

[root@localhost ~]# docker-machine regenerate-certs default
Regenerate TLS machine certs?  Warning: this is irreversible. (y/n): y
Regenerating TLS certificates
Waiting for SSH to be available...
Detecting the provisioner...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...

再次查看docker-machine状态,已恢复:

[root@localhost ~]# docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   -        virtualbox   Running   tcp://192.168.99.100:2376           v17.12.0-ce   
myvm1     -        virtualbox   Stopped                                       Unknown       
myvm2     -        virtualbox   Stopped                                       Unknown  

你可能感兴趣的:(docker)