安装docker报错Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon?

项目场景:

提示:在用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/*

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

万能解决方案:

扫描二维码关注公众号,回复: 11714880 查看本文章
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

 


解决方案:

提示: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

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

[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

systemctl status docker

 

猜你喜欢

转载自blog.csdn.net/as4589sd/article/details/108649200
今日推荐