ping www.baidu.com 正常结果: PING www.a.shifen.com (36.152.44.96) 56(84) bytes of data. 64 bytes from 36.152.44.96 (36.152.44.96): icmp_seq=1 ttl=128 time=4.02 ms 64 bytes from 36.152.44.96 (36.152.44.96): icmp_seq=2 ttl=128 time=4.89 ms 否则,需检查内部网络第二部:安装依赖包
sudo yum install -y yum-utils #缺少这些依赖将无法完成 执行结果: 已加载插件:fastestmirror Determining fastest mirrors * base: mirrors.ustc.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn base | 3.6 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/4): base/7/x86_64/group_gz | 153 kB 00:00:00 (2/4): extras/7/x86_64/primary_db | 246 kB 00:00:00 (3/4): base/7/x86_64/primary_db | 6.1 MB 00:00:13 (4/4): updates/7/x86_64/primary_db | 15 MB 00:00:18 正在解决依赖关系 --> 正在检查事务 ---> 软件包 yum-utils.noarch.0.1.1.31-54.el7_8 将被 安装 --> 正在处理依赖关系 python-kitchen,它被软件包 yum-utils-1.1.31-54.el7_8.noarch 需要 --> 正在处理依赖关系 libxml2-python,它被软件包 yum-utils-1.1.31-54.el7_8.noarch 需要 --> 正在检查事务 ---> 软件包 libxml2-python.x86_64.0.2.9.1-6.el7_9.6 将被 安装 --> 正在处理依赖关系 libxml2 = 2.9.1-6.el7_9.6,它被软件包 libxml2-python-2.9.1-6.el7_9.6.x86_64 需要 ---> 软件包 python-kitchen.noarch.0.1.1.1-5.el7 将被 安装 --> 正在处理依赖关系 python-chardet,它被软件包 python-kitchen-1.1.1-5.el7.noarch 需要 --> 正在检查事务 ---> 软件包 libxml2.x86_64.0.2.9.1-6.el7.4 将被 升级 ---> 软件包 libxml2.x86_64.0.2.9.1-6.el7_9.6 将被 更新 ---> 软件包 python-chardet.noarch.0.2.2.1-3.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 ============================================================================================================================================================================================================== Package 架构 版本 源 大小 ============================================================================================================================================================================================================== 正在安装: yum-utils noarch 1.1.31-54.el7_8 base 122 k 为依赖而安装: libxml2-python x86_64 2.9.1-6.el7_9.6 updates 247 k python-chardet noarch 2.2.1-3.el7 base 227 k python-kitchen noarch 1.1.1-5.el7 base 267 k 为依赖而更新: libxml2 x86_64 2.9.1-6.el7_9.6 updates 668 k 事务概要 ============================================================================================================================================================================================================== 安装 1 软件包 (+3 依赖软件包) 升级 ( 1 依赖软件包) 总下载量:1.5 M Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. 警告:/var/cache/yum/x86_64/7/base/packages/python-chardet-2.2.1-3.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY ] 468 kB/s | 498 kB 00:00:02 ETA python-chardet-2.2.1-3.el7.noarch.rpm 的公钥尚未安装 (1/5): python-chardet-2.2.1-3.el7.noarch.rpm | 227 kB 00:00:00 (2/5): python-kitchen-1.1.1-5.el7.noarch.rpm | 267 kB 00:00:01 libxml2-python-2.9.1-6.el7_9.6.x86_64.rpm 的公钥尚未安装 65% [=================================================== ] 541 kB/s | 1.0 MB 00:00:00 ETA (3/5): libxml2-python-2.9.1-6.el7_9.6.x86_64.rpm | 247 kB 00:00:01 (4/5): yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:01 (5/5): libxml2-2.9.1-6.el7_9.6.x86_64.rpm | 668 kB 00:00:01 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 总计 1.0 MB/s | 1.5 MB 00:00:01 从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥 导入 GPG key 0xF4A80EB5: 用户ID : "CentOS-7 Key (CentOS 7 Official Signing Key)第三步:查看docker版本,按照版本号从新到旧的顺序排列" 指纹 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 软件包 : centos-release-7-8.2003.0.el7.centos.x86_64 (@anaconda) 来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在更新 : libxml2-2.9.1-6.el7_9.6.x86_64 1/6 正在安装 : libxml2-python-2.9.1-6.el7_9.6.x86_64 2/6 正在安装 : python-chardet-2.2.1-3.el7.noarch 3/6 正在安装 : python-kitchen-1.1.1-5.el7.noarch 4/6 正在安装 : yum-utils-1.1.31-54.el7_8.noarch 5/6 清理 : libxml2-2.9.1-6.el7.4.x86_64 6/6 验证中 : python-chardet-2.2.1-3.el7.noarch 1/6 验证中 : libxml2-2.9.1-6.el7_9.6.x86_64 2/6 验证中 : libxml2-python-2.9.1-6.el7_9.6.x86_64 3/6 验证中 : python-kitchen-1.1.1-5.el7.noarch 4/6 验证中 : yum-utils-1.1.31-54.el7_8.noarch 5/6 验证中 : libxml2-2.9.1-6.el7.4.x86_64 6/6 已安装: yum-utils.noarch 0:1.1.31-54.el7_8 作为依赖被安装: libxml2-python.x86_64 0:2.9.1-6.el7_9.6 python-chardet.noarch 0:2.2.1-3.el7 python-kitchen.noarch 0:1.1.1-5.el7 作为依赖被升级: libxml2.x86_64 0:2.9.1-6.el7_9.6 完毕!
yum list docker-ce.x86_64 --showduplicates | sort -r 执行结果: 已加载插件:fastestmirror 可安装的软件包 * updates: mirrors.ustc.edu.cn Loading mirror speeds from cached hostfile * extras: mirrors.ustc.edu.cn docker-ce.x86_64 3:20.10.9-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.8-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.7-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.5-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.4-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.3-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.2-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.14-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.1-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.13-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.12-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.11-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.10-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.0-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.9-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.15-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.14-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.13-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.12-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.11-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.10-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable docker-ce.x86_64 3:18.09.9-3.el7 docker-ce-stable docker-ce.x86_64 3:18.09.8-3.el7 docker-ce-stable docker-ce.x86_64 3:18.09.7-3.el7 docker-ce-stable docker-ce.x86_64 3:18.09.6-3.el7 docker-ce-stable docker-ce.x86_64 3:18.09.5-3.el7 docker-ce-stable docker-ce.x86_64 3:18.09.4-3.el7 docker-ce-stable docker-ce.x86_64 3:18.09.3-3.el7 docker-ce-stable docker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stable docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable * base: mirrors.ustc.edu.cn第四步:安装docker
安装指定版本docker: yum install docker-ce-18.09.9 docker-ce-cli-18.09.9 containerd.io 安装最新版本docker: yum -y install docker-ce 执行结果: 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.ustc.edu.cn * extras: mirrors.ustc.edu.cn * updates: mirrors.ustc.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 docker-ce.x86_64.3.20.10.14-3.el7 将被 安装 --> 正在处理依赖关系 containerd.io >= 1.4.1,它被软件包 3:docker-ce-20.10.14-3.el7.x86_64 需要 --> 正在处理依赖关系 docker-ce-cli,它被软件包 3:docker-ce-20.10.14-3.el7.x86_64 需要 --> 正在处理依赖关系 docker-ce-rootless-extras,它被软件包 3:docker-ce-20.10.14-3.el7.x86_64 需要 --> 正在检查事务 ---> 软件包 containerd.io.x86_64.0.1.5.11-3.1.el7 将被 安装 ---> 软件包 docker-ce-cli.x86_64.1.20.10.14-3.el7 将被 安装 --> 正在处理依赖关系 docker-scan-plugin(x86-64),它被软件包 1:docker-ce-cli-20.10.14-3.el7.x86_64 需要 ---> 软件包 docker-ce-rootless-extras.x86_64.0.20.10.14-3.el7 将被 安装 --> 正在处理依赖关系 fuse-overlayfs >= 0.7,它被软件包 docker-ce-rootless-extras-20.10.14-3.el7.x86_64 需要 --> 正在处理依赖关系 slirp4netns >= 0.4,它被软件包 docker-ce-rootless-extras-20.10.14-3.el7.x86_64 需要 --> 正在检查事务 ---> 软件包 docker-scan-plugin.x86_64.0.0.17.0-3.el7 将被 安装 ---> 软件包 fuse-overlayfs.x86_64.0.0.7.2-6.el7_8 将被 安装 --> 正在处理依赖关系 libfuse3.so.3(FUSE_3.2)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要 --> 正在处理依赖关系 libfuse3.so.3(FUSE_3.0)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要 --> 正在处理依赖关系 libfuse3.so.3()(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要 ---> 软件包 slirp4netns.x86_64.0.0.4.3-4.el7_8 将被 安装 --> 正在检查事务 ---> 软件包 fuse3-libs.x86_64.0.3.6.1-4.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 ============================================================================================================================================================================================================== Package 架构 版本 源 大小 ============================================================================================================================================================================================================== 正在安装: docker-ce x86_64 3:20.10.14-3.el7 docker-ce-stable 22 M 为依赖而安装: containerd.io x86_64 1.5.11-3.1.el7 docker-ce-stable 29 M docker-ce-cli x86_64 1:20.10.14-3.el7 docker-ce-stable 30 M docker-ce-rootless-extras x86_64 20.10.14-3.el7 docker-ce-stable 8.1 M docker-scan-plugin x86_64 0.17.0-3.el7 docker-ce-stable 3.7 M fuse-overlayfs x86_64 0.7.2-6.el7_8 extras 54 k fuse3-libs x86_64 3.6.1-4.el7 extras 82 k slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k 事务概要 ============================================================================================================================================================================================================== 安装 1 软件包 (+7 依赖软件包) 总计:94 M 总下载量:93 M 安装大小:378 M Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. (1/5): docker-ce-20.10.14-3.el7.x86_64.rpm | 22 MB 00:00:30 (2/5): containerd.io-1.5.11-3.1.el7.x86_64.rpm | 29 MB 00:00:42 (3/5): docker-ce-rootless-extras-20.10.14-3.el7.x86_64.rpm | 8.1 MB 00:00:09 (4/5): docker-scan-plugin-0.17.0-3.el7.x86_64.rpm | 3.7 MB 00:00:04 (5/5): docker-ce-cli-20.10.14-3.el7.x86_64.rpm | 30 MB 00:00:36 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 总计 1.4 MB/s | 93 MB 00:01:07 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : docker-scan-plugin-0.17.0-3.el7.x86_64 1/8 正在安装 : 1:docker-ce-cli-20.10.14-3.el7.x86_64 2/8 正在安装 : slirp4netns-0.4.3-4.el7_8.x86_64 3/8 正在安装 : fuse3-libs-3.6.1-4.el7.x86_64 4/8 正在安装 : fuse-overlayfs-0.7.2-6.el7_8.x86_64 5/8 正在安装 : containerd.io-1.5.11-3.1.el7.x86_64 6/8 正在安装 : docker-ce-rootless-extras-20.10.14-3.el7.x86_64 7/8 正在安装 : 3:docker-ce-20.10.14-3.el7.x86_64 8/8 验证中 : 3:docker-ce-20.10.14-3.el7.x86_64 1/8 验证中 : containerd.io-1.5.11-3.1.el7.x86_64 2/8 验证中 : fuse3-libs-3.6.1-4.el7.x86_64 3/8 验证中 : fuse-overlayfs-0.7.2-6.el7_8.x86_64 4/8 验证中 : docker-ce-rootless-extras-20.10.14-3.el7.x86_64 5/8 验证中 : slirp4netns-0.4.3-4.el7_8.x86_64 6/8 验证中 : 1:docker-ce-cli-20.10.14-3.el7.x86_64 7/8 验证中 : docker-scan-plugin-0.17.0-3.el7.x86_64 8/8 已安装: docker-ce.x86_64 3:20.10.14-3.el7 作为依赖被安装: containerd.io.x86_64 0:1.5.11-3.1.el7 docker-ce-cli.x86_64 1:20.10.14-3.el7 docker-ce-rootless-extras.x86_64 0:20.10.14-3.el7 docker-scan-plugin.x86_64 0:0.17.0-3.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7 slirp4netns.x86_64 0:0.4.3-4.el7_8 完毕!第五部:查看docker版本
docker version 执行结果: Client: Docker Engine - Community Version: 20.10.14 API version: 1.41 Go version: go1.16.15 Git commit: a224086 Built: Thu Mar 24 01:49:57 2022 OS/Arch: linux/amd64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.14 API version: 1.41 (minimum version 1.12) Go version: go1.16.15 Git commit: 87a90dc Built: Thu Mar 24 01:48:24 2022 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.5.11 GitCommit: 3df54a852345ae127d1fa3092b95168e4a88e2f8 runc: Version: 1.0.3 GitCommit: v1.0.3-0-gf46b6ba docker-init: Version: 0.19.0 GitCommit: de40ad0第六步:查看docker服务运行状态
systemctl status docker
执行结果:
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since 四 2022-04-28 15:55:32 CST; 1min 7s ago
Docs: https://docs.docker.com
Main PID: 19102 (dockerd)
Tasks: 7
Memory: 31.7M
CGroup: /system.slice/docker.service
└─19102 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
4月 28 15:55:32 localhost.localdomain dockerd[19102]: time="2022-04-28T15:55:32.379048634+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/container..." module=grpc
4月 28 15:55:32 localhost.localdomain dockerd[19102]: time="2022-04-28T15:55:32.379054483+08:00" level=info msg="ClientConn switching balancer to "pick_first"" module=grpc
4月 28 15:55:32 localhost.localdomain dockerd[19102]: time="2022-04-28T15:55:32.392481842+08:00" level=info msg="Loading containers: start."
4月 28 15:55:32 localhost.localdomain dockerd[19102]: time="2022-04-28T15:55:32.732915316+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemo...d IP address"
4月 28 15:55:32 localhost.localdomain dockerd[19102]: time="2022-04-28T15:55:32.795814600+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
4月 28 15:55:32 localhost.localdomain dockerd[19102]: time="2022-04-28T15:55:32.853827026+08:00" level=info msg="Loading containers: done."
4月 28 15:55:32 localhost.localdomain dockerd[19102]: time="2022-04-28T15:55:32.865393249+08:00" level=info msg="Docker daemon" commit=87a90dc graphdriver(s)=overlay2 version=20.10.14
4月 28 15:55:32 localhost.localdomain dockerd[19102]: time="2022-04-28T15:55:32.865470553+08:00" level=info msg="Daemon has completed initialization"
4月 28 15:55:32 localhost.localdomain dockerd[19102]: time="2022-04-28T15:55:32.878616233+08:00" level=info msg="API listen on /var/run/docker.sock"
4月 28 15:55:32 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
第七步:在docker中pull镜像
docker pull centos 执行结果: Using default tag: latest latest: Pulling from library/centos a1d0c7532777: Pull complete Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177 Status: Downloaded newer image for centos:latest docker.io/library/centos:latest
PS:如果pull镜像后报错
Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: TLS handshake timeout
则需要进入 /etc/docker 目录下打开daemon.json 文件,如果没有这个文件,手动新建下
文件内容:
{
"registry-mirrors":["http://docker.mirrors.ustc.edu.cn"]
}
保存退出,执行重启docker命令
第八步:校验docker$ docker run hello-world
执行结果:
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/
docker常用命令:
docker --help #帮助
docker –v #简单查看版本
docker version #查看版本
docker info #查看信息



