背景:
在虚拟机上的centos7安装docker,查看docker version时,报错
报错信息:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@node1 ~]# docker version
Client: Docker Engine - Community
Version: 20.10.5
API version: 1.41
Go version: go1.13.15
Git commit: 55c4c88
Built: Tue Mar 2 20:33:55 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
原因:
配置镜像加速器的时候。修改daemon配置文件/etc/docker/daemon.json,里面的阿里云加速器用错了,我直接copy了别人的url,后面才值得,阿里云的镜像加速url可以用自己的。
在https://cr.console.aliyun.com这里登陆自己的账号(没有账号就注册一个),然后找到容器镜像服务,里面就有自己可以用的加速器了。我真是个憨批~
解决办法:
步骤1:重新配置自己的daemon文件被,把url换成自己的
[root@node1 ~]# cat > /etc/docker/daemon.json << EOF
> {
> "registry-mirrors": ["https://XXXXXX.mirror.aliyuncs.com"]
> }
> EOF
步骤2:重启docker
systemctl restart docker
步骤3:重新查看docker version
[root@node1 ~]# docker version
Client: Docker Engine - Community
Version: 20.10.5
API version: 1.41
Go version: go1.13.15
Git commit: 55c4c88
Built: Tue Mar 2 20:33:55 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.5
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: 363e9a8
Built: Tue Mar 2 20:32:17 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.4
GitCommit: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e
runc:
Version: 1.0.0-rc93
GitCommit: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
docker-init:
Version: 0.19.0
GitCommit: de40ad0
就ok了,反正我是挺傻的,记录一下憨批时刻