Docker 报错 certificate has expired or is not yet valid 解决方法

Docker 报错 certificate has expired or is not yet valid

$ docker-machine start default

Starting "default"...
(default) Check network to re-create if needed...
(default) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar.
(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 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 has expired or is not yet valid
dev        -        virtualbox   Stopped                                       Unknown
mydocker   -        virtualbox   Error                                         Unknown   machine does not exist

$  docker images

error during connect: Get https://192.168.99.100:2376/v1.39/images/json: x509: certificate has expired or is not yet valid

解决

$ docker-machine regenerate-certs --client-certs

Regenerate TLS machine certs?  Warning: this is irreversible. (y/n): y
Regenerating TLS certificates
Regenerating local certificates
CA certificate is outdated and needs to be regenerated
Creating CA: C:\Users\chenh\.docker\machine\certs\ca.pem
Client certificate is outdated and needs to be regenerated
Creating client certificate: C:\Users\chenh\.docker\machine\certs\cert.pem
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 ls

NAME       ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
default    *        virtualbox   Running   tcp://192.168.99.100:2376           v18.09.7
dev        -        virtualbox   Stopped                                       Unknown
mydocker   -        virtualbox   Error                                         Unknown    machine does not exist

# 恢复正常
$ docker images

REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
golang                1.17.5-buster       60cae92293cf        7 months ago        884MB
golang                1.16.6-alpine3.14   7762f5dece68        12 months ago       302MB
proxysql/proxysql     latest              4d3259803777        13 months ago       230MB
openresty/openresty   latest              95552c9e9f70        20 months ago       85.3MB
postgres              latest              817f2d3d51ec        22 months ago       314MB
nginx                 latest              7e4d58f0e5f3        22 months ago       133MB
mysql                 5.7                 9cfcce23593a        2 years ago         448MB
mysql                 latest              be0dbf01a0f3        2 years ago         541MB

参考

  • https://stackoverflow.com/questions/35289802/docker-pull-error-x509-certificate-has-expired-or-is-not-yet-valid Docker pull error : x509: certificate has expired or is not yet valid

猜你喜欢

转载自blog.csdn.net/xchenhao/article/details/126034614