docker报错
新弄了个服务器,使用xshell7
版本,进行了如下安装并启动docker
的操作:
# 先卸载旧的docker版本
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
# 安装工具包
yum install -y yum-utils
# 设置仓库
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # 这个是阿里云镜像,用这个
# 更新yum缓存
yum makecache fast
# 安装docker
yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
# 启动docker
systemctl start docker
# 查看docker版本信息
docker version
此时,docker
安装成功并启动,显示信息如下:
[root@VM-4-8-centos /]# docker version
Client: Docker Engine - Community
Version: 20.10.18
API version: 1.41
Go version: go1.18.6
Git commit: b40c2f6
Built: Thu Sep 8 23:14:08 2022
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?
报错内容为:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
错误排查与解决
按照报错内容提示,说明少运行了daemon
,于是百度运行命令,然后运行:
[root@VM-4-8-centos /]# systemctl daemon-reload
[root@VM-4-8-centos /]# systemctl restart docker.service
再重新查看,没有报错了:
检查测试
最简单的方法就是跑一遍hello-world
镜像进行测试:
[root@VM-4-8-centos /]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:62af9efd515a25f84961b70f973a798d2eca956b1b2b026d0a4a63a3b0b6a3f2
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
ok,没问题了。
参考文档
https://blog.csdn.net/qq_42114918/article/details/81840335