docker 出现 Error checking TLS connection 的解决方案

当我们想执行 eval $(docker-machine env) 来加载 docker 服务器的环境变量时,却出现如下错误:

Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376": dial tcp 192.168.99.100:2376: i/o timeout
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which will stop running containers.

根据提示,我们执行 docker-machine regenerate-certs,这次提示:

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...

This machine has been allocated an IP address, but Docker Machine could not
reach it successfully.
SSH for the machine should still work, but connecting to exposed ports, such as
the Docker daemon port (usually <ip>:2376), may not work properly.
You may need to add the route manually, or use another related workaround.
This could be due to a VPN, proxy, or host file configuration issue.
You also might want to clear any VirtualBox host only interfaces you are not using.

看起来仍然不行,仍旧是连接不到服务器,那服务器到底能不能连上呢?用 docker-machine ssh 竟然可以!让我们重启一下 docker-machine restart 试试。仍然不行。

那该怎么办?经过一番搜索,很多人都出现过这个问题,出现的情境基本和我一致——docker 服务器(虚拟机)所处网段与其他网卡的网段重叠了,导致连接不上。

我的情况是,家用路由器的网段和 docker-machine create 时默认使用的网段重叠了,所以每次回家再回到公司就会发现 docker 废掉了,一开始只能删掉重建虚拟机,后来发现了以下三种解决方案:

  1. 关掉 TLS 检查。不推荐。
  2. 创建虚拟机时指定其他网段:docker-machine create -d virtualbox --virtualbox-hostonly-cidr "192.168.90.1/24" default
  3. 修改其他网卡的网段,然后删掉 docker 虚拟机使用的网卡,再执行 docker-machine start,这会重建网卡。

转载于:https://my.oschina.net/tridays/blog/810568

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值