用rancher创建k8s时,docker报错Cannot connect to the Docker daemon at unix:///var/run/docker.sock等一系列踩坑过程

项目场景:

提示:在用rancher创建k8s的时候,其中一台服务器,报Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?


问题描述:

于是到该台服务器,查看原因,无论是docker run helloworld ,还是docker info,都报Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
于是查看日志

systemctl status docker

● docker.service - Docker Application Container Engine
Loaded: loaded (/etc/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since 四 2020-09-17 17:18:16 CST; 1s ago
Docs: http://docs.docker.io
Process: 6430 ExecStartPost=/sbin/iptables -I FORWARD -s 0.0.0.0/0 -j ACCEPT (code=exited, status=0/SUCCESS)
Process: 6429 ExecStart=/opt/kube/bin/dockerd --registry-mirror=http://3cda3ca9.m.daocloud.io -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 (code=exited, status=1/FAILURE)
Main PID: 6429 (code=exited, status=1/FAILURE)

9月 17 17:18:16 cdh2-4 systemd[1]: Unit docker.service entered failed state.
9月 17 17:18:16 cdh2-4 systemd[1]: docker.service failed.

再看详细日志

journalctl -u docker.service 

9月 08 21:12:32 cdh2-4 systemd[1]: Starting Docker Application Container Engine...
9月 08 21:12:32 cdh2-4 dockerd[17900]: time="2020-09-08T21:12:32.921547656+08:00" level=warning msg="could not change group /var/run/docker.sock to docker: group docker not found"
9月 08 21:12:32 cdh2-4 dockerd[17900]: time="2020-09-08T21:12:32.953783378+08:00" level=warning msg="failed to load plugin io.containerd.snapshotter.v1.btrfs" error="path /var/lib/docker/contain
9月 08 21:12:32 cdh2-4 dockerd[17900]: time="2020-09-08T21:12:32.956534309+08:00" level=warning msg="failed to load plugin io.containerd.snapshotter.v1.aufs" error="modprobe aufs failed: "modpro
9月 08 21:12:32 cdh2-4 dockerd[17900]: time="2020-09-08T21:12:32.957510869+08:00" level=warning msg="could not use snapshotter zfs in metadata plugin" error="path /var/lib/docker/containerd/daem
9月 08 21:12:32 cdh2-4 dockerd[17900]: time="2020-09-08T21:12:32.957525885+08:00" level=warning msg="could not use snapshotter btrfs in metadata plugin" error="path /var/lib/docker/containerd/da
9月 08 21:12:32 cdh2-4 dockerd[17900]: time="2020-09-08T21:12:32.957533745+08:00" level=warning msg="could not use snapshotter aufs in metadata plugin" error="modprobe aufs failed: "modprobe: FA
9月 08 21:12:33 cdh2-4 systemd[1]: Started Docker Application Container Engine.

原因分析:

经过反复折腾,重装,采用不同的镜像源,同时采用检查docker环境的配置check-config.sh,根据其扫描的结果,百度和google,解决一部分问题!

./check-config.sh  

其中出现 (RHEL7/CentOS7: User namespaces disabled; add 'user_namespace.enable=1' to boot command line)

解决方案:

groupadd docker
usermod -aG docker $(whoami)
service docker start

其他问题的解决:

1,运行yum list installed | grep docker命令,提示Repository epel is listed more than once in the configuration

解决方案:

zip centos7-repo.zip /etc/yum.repos.d/* 

对原来的配置项进行备份,有备无患!

万能解决方案:

cd /etc/yum.repos.d/
wget http://mirrors.aliyun.com/repo/Centos-7.repo
sed -i 's/^.*aliyuncs*/#&/g' /etc/yum.repos.d/CentOS-Base.repo
wget https://mirrors.aliyun.com/repo/epel-7.repo

2,在centos7 中docker info报错docker bridge-nf-call-iptables is disabled解决办法

解决方案:

cat > /etc/sysctl.d/docker.conf <<-'EOF'
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-arptables = 1
EOF

sysctl --system
sysctl -p

3,查看docker有哪些rpm,干掉! 

yum list installed | grep docker
yum -y remove docker-ce-cli.x86_64
yum -y remove containerd.io.x86_64

 4,备份/etc/docker/daemon.json,用过很多家的镜像,测试了很多,还是阿里比较靠谱

cat >/etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors":["https://jnxt8d8b.mirror.aliyuncs.com"]
}
EOF

systemctl daemon-reload && systemctl restart docker
5,这时候,docker info一下

systemctl status docker
docker info

 用rancher创建k8s时,docker报错Cannot connect to the Docker daemon at unix:///var/run/docker.sock等一系列踩坑过程


解决方案:

提示:docker报错Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon?
该怎么办呢?

遇见bug,职业病,还是不肯放过它……这是错误,吃点东西,喝杯咖啡……估计走火入魔了……

再来看看

systemctl status docker 

docker.service - Docker Application Container Engine
Loaded: loaded (/etc/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since 四 2020-09-17 17:49:59 CST; 466ms ago
Docs: http://docs.docker.io
Process: 15193 ExecStartPost=/sbin/iptables -I FORWARD -s 0.0.0.0/0 -j ACCEPT (code=exited, status=0/SUCCESS)
Process: 15192 ExecStart=/opt/kube/bin/dockerd --registry-mirror=http://3cda3ca9.m.daocloud.io -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 (code=exited, status=1/FAILURE)
Main PID: 15192 (code=exited, status=1/FAILURE)

1,把--registry-mirror=http://3cda3ca9.m.daocloud.io这个去掉

vim /etc/systemd/system/docker.service 

用rancher创建k8s时,docker报错Cannot connect to the Docker daemon at unix:///var/run/docker.sock等一系列踩坑过程

不知道看哪个博客,手贱加上的!去掉以后

[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.io

[Service]
Environment="PATH=/opt/kube/bin:/bin:/sbin:/usr/bin:/usr/sbin"
ExecStart=/opt/kube/bin/dockerd -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375
ExecStartPost=/sbin/iptables -I FORWARD -s 0.0.0.0/0 -j ACCEPT
ExecReload=/bin/kill -s HUP $MAINPID
Restart=always
RestartSec=5
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Delegate=yes
KillMode=process

[Install]
WantedBy=multi-user.target

2,Cannot connect to the Docker daemon at tcp://0.0.0.0:2375. Is the docker daemon 

解决方案:

echo 'export DOCKER_HOST=tcp://0.0.0.0:2375' >> /etc/profile
source /etc/profile
systemctl daemon-reload && systemctl restart docker

友情链接:https://www.cnblogs.com/weiyiming007/p/10168733.html

最后docker info一下,解决问题!

docker info 

用rancher创建k8s时,docker报错Cannot connect to the Docker daemon at unix:///var/run/docker.sock等一系列踩坑过程

systemctl status docker 

 用rancher创建k8s时,docker报错Cannot connect to the Docker daemon at unix:///var/run/docker.sock等一系列踩坑过程

原创:https://www.panoramacn.com
源码网提供WordPress源码,帝国CMS源码discuz源码,微信小程序,小说源码,杰奇源码,thinkphp源码,ecshop模板源码,微擎模板源码,dede源码,织梦源码等。

专业搭建小说网站,小说程序,杰奇系列,微信小说系列,app系列小说

用rancher创建k8s时,docker报错Cannot connect to the Docker daemon at unix:///var/run/docker.sock等一系列踩坑过程

免责声明,若由于商用引起版权纠纷,一切责任均由使用者承担。

您必须遵守我们的协议,如果您下载了该资源行为将被视为对《免责声明》全部内容的认可-> 联系客服 投诉资源
www.panoramacn.com资源全部来自互联网收集,仅供用于学习和交流,请勿用于商业用途。如有侵权、不妥之处,请联系站长并出示版权证明以便删除。 敬请谅解! 侵权删帖/违法举报/投稿等事物联系邮箱:2640602276@qq.com
未经允许不得转载:书荒源码源码网每日更新网站源码模板! » 用rancher创建k8s时,docker报错Cannot connect to the Docker daemon at unix:///var/run/docker.sock等一系列踩坑过程
关注我们小说电影免费看
关注我们,获取更多的全网素材资源,有趣有料!
120000+人已关注
分享到:
赞(0) 打赏

评论抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

您的打赏就是我分享的动力!

支付宝扫一扫打赏

微信扫一扫打赏