温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用docker创建calico网络失败怎么办

发布时间:2021-11-19 11:00:26 来源:亿速云 阅读:586 作者:小新 栏目:云计算

这篇文章给大家分享的是有关使用docker创建calico网络失败怎么办的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

使用docker创建calico网络失败。

# docker network create --driver calico --ipam-driver calico-ipam testcalico
Error response from daemon: failed to update store for object type *libnetwork.endpointCnt: client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint.

查看docker日志:

# journalctl -fu docker
-- Logs begin at Sun 2018-05-06 10:42:10 CST. --
May 06 10:51:11 gpu16 dockerd[1045]: time="2018-05-06T10:51:11.997488908+08:00" level=warning msg="Registering as \"192.168.56.16:2375\" in discovery failed: client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint."
May 06 10:51:13 gpu16 dockerd[1045]: time="2018-05-06T10:51:13.209441579+08:00" level=error msg="discovery error: client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint."
May 06 10:51:13 gpu16 dockerd[1045]: time="2018-05-06T10:51:13.211323271+08:00" level=error msg="discovery error: client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint."
May 06 10:51:13 gpu16 dockerd[1045]: time="2018-05-06T10:51:13.213320054+08:00" level=error msg="discovery error: Unexpected watch error"

首先想到的错误原因可能是:calico网络后台的分布式存储是etcd,而环境中使用的V3版本的etcd,而该版本在API方面既支持V2又支持V3。docker中未正确配置需要的版本,即docker要求使用的etcd API版本和etcd提供的API版本不一致,导致出现该问题。
验证:命令行手动去获取etcd的版本号:curl http://<etcd_ip>:2379/version

# curl http://192.168.56.96:2379/version
{"etcdserver":"3.1.9","etcdcluster":"3.1.0"}

返回正常。
看到http,忽然想到我们的环境访问http和https是需要设置代理http_proxy和https_proxy,同样,也需要设置no_proxy来过滤不使用代理的IP。如果要访问的IP不在no_proxy的范围内,代理就会返回非法的http应答,而这个应答不是json格式的,很可能就对应了错误日志中的“response is invalid json”部分。在环境变量中,已经设置了http_proxy,https_proxy和no_proxy,但是,docker不能使用操作系统的这三个环境变量,我们需要配置docker的这三个环境变量。而且,在创建calico网络时,docker会通过http请求向etcd注册,因此在no_proxy中需要包含etcd集群的IP

# mkdir -p /etc/systemd/system/docker.service.d/
# vim /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://192.168.11.200:8080/" "HTTPS_PROXY=https://192.168.11.200:8080/" "NO_PROXY=192.168.56.109,192.168.56.96"

# systemctl daemon-reload
# systemctl restart docker

待docker服务重启完毕,再尝试创建calico网络,成功。

# docker network create --driver calico --ipam-driver calico-ipam testcalico
53cbe9b82451b017be6d5d80a8fc17e320f6269521dfeabb7e07fd79ee92e3ef

感谢各位的阅读!关于“使用docker创建calico网络失败怎么办”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI