Centos安装docker


本文中全部操作都是根据官方文档给出的步骤实操记录下的,如有错误请指正

互联网环境

#首先确保自己服务器是联通互联网
[root@DESKTOP-CHAI /]# ping www.baidu.com
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from www.baidu.com (14.215.177.39): icmp_seq=1 ttl=54 time=37.5 ms
64 bytes from www.baidu.com (14.215.177.39): icmp_seq=2 ttl=54 time=37.2 ms
64 bytes from www.baidu.com (14.215.177.39): icmp_seq=3 ttl=54 time=37.4 ms
64 bytes from www.baidu.com (14.215.177.39): icmp_seq=4 ttl=54 time=37.2 ms

centos安装docker官方文档
可以根据官方文档步骤一步步进行安装(docker官方文档还是很详细的)

1.卸载旧版本docker(Uninstall old versions)

#执行官方给出的删除旧版本docker的命令
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
#简化成一行命令不分行
yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
#以下为我执行删除命令的结果
[root@DESKTOP-CHAI /]# yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
Loaded plugins: fastestmirror, ovl
No Match for argument: docker
No Match for argument: docker-client
No Match for argument: docker-client-latest
No Match for argument: docker-common
No Match for argument: docker-latest
No Match for argument: docker-latest-logrotate
No Match for argument: docker-logrotate
No Match for argument: docker-engine
No Packages marked for removal
[root@DESKTOP-CHAI /]#

2.安装 Docker

Install using the repository

#安装yum-utils包
yum install -y yum-utils
#以下为执行结果
[root@DESKTOP-CHAI /]# yum install -y yum-utils
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.163.com
base                                                                                                                                                                                      | 3.6 kB  00:00:00
extras                                                                                                                                                                                    | 2.9 kB  00:00:00
updates                                                                                                                                                                                   | 2.9 kB  00:00:00
(1/4): extras/7/x86_64/primary_db                                                                                                                                                         | 242 kB  00:00:00
(2/4): base/7/x86_64/group_gz                                                                                                                                                             | 153 kB  00:00:00
(3/4): updates/7/x86_64/primary_db                                                                                                                                                        | 9.5 MB  00:00:00
(4/4): base/7/x86_64/primary_db                                                                                                                                                           | 6.1 MB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-50.el7 will be updated
---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================================
 Package                                            Arch                                            Version                                                  Repository                                     Size
=================================================================================================================================================================================================================
Updating:
 yum-utils                                          noarch                                          1.1.31-54.el7_8                                          base                                          122 k

Transaction Summary
=================================================================================================================================================================================================================
Upgrade  1 Package

Total download size: 122 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/base/packages/yum-utils-1.1.31-54.el7_8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for yum-utils-1.1.31-54.el7_8.noarch.rpm is not installed
yum-utils-1.1.31-54.el7_8.noarch.rpm                                                                                                                                                      | 122 kB  00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@CentOS)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : yum-utils-1.1.31-54.el7_8.noarch                                                                                                                                                              1/2
  Cleanup    : yum-utils-1.1.31-50.el7.noarch                                                                                                                                                                2/2
  Verifying  : yum-utils-1.1.31-54.el7_8.noarch                                                                                                                                                              1/2
  Verifying  : yum-utils-1.1.31-50.el7.noarch                                                                                                                                                                2/2

Updated:
  yum-utils.noarch 0:1.1.31-54.el7_8

Complete!
[root@DESKTOP-CHAI /]#
#官方源地址(比较慢)
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
#可以选择国内的一些源地址
#阿里云
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#清华大学源
yum-config-manager --add-repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
#使用阿里云源
[root@DESKTOP-CHAI /]# yum-config-manager \
>     --add-repo \
  http:>     http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, ovl
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
安装最新版本的 Docker Engine 和 containerd
#安装
yum install docker-ce docker-ce-cli containerd.io
#执行结果
[root@DESKTOP-CHAI /]# yum install docker-ce docker-ce-cli containerd.io
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.163.com
docker-ce-stable                                                                                                                                                                          | 3.5 kB  00:00:00
(1/2): docker-ce-stable/7/x86_64/primary_db                                                                                                                                               |  62 kB  00:00:00
(2/2): docker-ce-stable/7/x86_64/updateinfo                                                                                                                                               |   55 B  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.4.8-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.4.8-3.1.el7.x86_64
--> Processing Dependency: libseccomp for package: containerd.io-1.4.8-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:20.10.7-3.el7 will be installed
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.7-3.el7.x86_64
--> Processing Dependency: iptables for package: 3:docker-ce-20.10.7-3.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-20.10.7-3.el7.x86_64
---> Package docker-ce-cli.x86_64 1:20.10.7-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.7-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Processing Dependency: selinux-policy-targeted >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
--> Processing Dependency: selinux-policy-base >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
--> Processing Dependency: selinux-policy >= 3.13.1-216.el7 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
--> Processing Dependency: policycoreutils >= 2.5-11 for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
--> Processing Dependency: libselinux-utils for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
---> Package docker-ce-rootless-extras.x86_64 0:20.10.7-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64
---> Package docker-scan-plugin.x86_64 0:0.8.0-3.el7 will be installed
---> Package iptables.x86_64 0:1.4.21-35.el7 will be installed
--> Processing Dependency: libnfnetlink.so.0()(64bit) for package: iptables-1.4.21-35.el7.x86_64
--> Processing Dependency: libnetfilter_conntrack.so.3()(64bit) for package: iptables-1.4.21-35.el7.x86_64
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
---> Package libseccomp.x86_64 0:2.3.1-4.el7 will be installed
--> Running transaction check
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package libnetfilter_conntrack.x86_64 0:1.0.6-1.el7_3 will be installed
--> Processing Dependency: libmnl.so.0(LIBMNL_1.1)(64bit) for package: libnetfilter_conntrack-1.0.6-1.el7_3.x86_64
--> Processing Dependency: libmnl.so.0(LIBMNL_1.0)(64bit) for package: libnetfilter_conntrack-1.0.6-1.el7_3.x86_64
--> Processing Dependency: libmnl.so.0()(64bit) for package: libnetfilter_conntrack-1.0.6-1.el7_3.x86_64
---> Package libnfnetlink.x86_64 0:1.0.1-4.el7 will be installed
---> Package libselinux-utils.x86_64 0:2.5-15.el7 will be installed
--> Processing Dependency: libselinux(x86-64) = 2.5-15.el7 for package: libselinux-utils-2.5-15.el7.x86_64
---> Package policycoreutils.x86_64 0:2.5-34.el7 will be installed
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libselinux-python for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
---> Package selinux-policy.noarch 0:3.13.1-268.el7_9.2 will be installed
---> Package selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2 will be installed
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
--> Processing Dependency: audit-libs(x86-64) = 2.8.5-4.el7 for package: audit-libs-python-2.8.5-4.el7.x86_64
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
---> Package libmnl.x86_64 0:1.0.3-7.el7 will be installed
---> Package libselinux.x86_64 0:2.5-14.1.el7 will be updated
---> Package libselinux.x86_64 0:2.5-15.el7 will be an update
---> Package libselinux-python.x86_64 0:2.5-15.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Running transaction check
---> Package audit-libs.x86_64 0:2.8.4-4.el7 will be updated
---> Package audit-libs.x86_64 0:2.8.5-4.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================================
 Package                                                  Arch                                  Version                                                    Repository                                       Size
=================================================================================================================================================================================================================
Installing:
 containerd.io                                            x86_64                                1.4.8-3.1.el7                                              docker-ce-stable                                 30 M
 docker-ce                                                x86_64                                3:20.10.7-3.el7                                            docker-ce-stable                                 27 M
 docker-ce-cli                                            x86_64                                1:20.10.7-3.el7                                            docker-ce-stable                                 33 M
Installing for dependencies:
 audit-libs-python                                        x86_64                                2.8.5-4.el7                                                base                                             76 k
 checkpolicy                                              x86_64                                2.5-8.el7                                                  base                                            295 k
 container-selinux                                        noarch                                2:2.119.2-1.911c772.el7_8                                  extras                                           40 k
 docker-ce-rootless-extras                                x86_64                                20.10.7-3.el7                                              docker-ce-stable                                9.2 M
 docker-scan-plugin                                       x86_64                                0.8.0-3.el7                                                docker-ce-stable                                4.2 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
 iptables                                                 x86_64                                1.4.21-35.el7                                              base                                            432 k
 libcgroup                                                x86_64                                0.41-21.el7                                                base                                             66 k
 libmnl                                                   x86_64                                1.0.3-7.el7                                                base                                             23 k
 libnetfilter_conntrack                                   x86_64                                1.0.6-1.el7_3                                              base                                             55 k
 libnfnetlink                                             x86_64                                1.0.1-4.el7                                                base                                             26 k
 libseccomp                                               x86_64                                2.3.1-4.el7                                                base                                             56 k
 libselinux-python                                        x86_64                                2.5-15.el7                                                 base                                            236 k
 libselinux-utils                                         x86_64                                2.5-15.el7                                                 base                                            151 k
 libsemanage-python                                       x86_64                                2.5-14.el7                                                 base                                            113 k
 policycoreutils                                          x86_64                                2.5-34.el7                                                 base                                            917 k
 policycoreutils-python                                   x86_64                                2.5-34.el7                                                 base                                            457 k
 python-IPy                                               noarch                                0.75-6.el7                                                 base                                             32 k
 selinux-policy                                           noarch                                3.13.1-268.el7_9.2                                         updates                                         498 k
 selinux-policy-targeted                                  noarch                                3.13.1-268.el7_9.2                                         updates                                         7.0 M
 setools-libs                                             x86_64                                3.3.8-4.el7                                                base                                            620 k
 slirp4netns                                              x86_64                                0.4.3-4.el7_8                                              extras                                           81 k
Updating for dependencies:
 audit-libs                                               x86_64                                2.8.5-4.el7                                                base                                            102 k
 libselinux                                               x86_64                                2.5-15.el7                                                 base                                            162 k

Transaction Summary
=================================================================================================================================================================================================================
Install  3 Packages (+23 Dependent packages)
Upgrade             (  2 Dependent packages)

Total download size: 114 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/28): audit-libs-python-2.8.5-4.el7.x86_64.rpm                                                                                                                                          |  76 kB  00:00:00
(2/28): audit-libs-2.8.5-4.el7.x86_64.rpm                                                                                                                                                 | 102 kB  00:00:00
(3/28): checkpolicy-2.5-8.el7.x86_64.rpm                                                                                                                                                  | 295 kB  00:00:00
(4/28): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm                                                                                                                              |  40 kB  00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.7-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY                          ]  16 MB/s |  47 MB  00:00:04 ETA
Public key for docker-ce-20.10.7-3.el7.x86_64.rpm is not installed
(5/28): docker-ce-20.10.7-3.el7.x86_64.rpm                                                                                                                                                |  27 MB  00:00:01
(6/28): containerd.io-1.4.8-3.1.el7.x86_64.rpm                                                                                                                                            |  30 MB  00:00:02
(7/28): docker-ce-rootless-extras-20.10.7-3.el7.x86_64.rpm                                                                                                                                | 9.2 MB  00:00:00
(8/28): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm                                                                                                                                           |  54 kB  00:00:00
(9/28): fuse3-libs-3.6.1-4.el7.x86_64.rpm                                                                                                                                                 |  82 kB  00:00:00
(10/28): libcgroup-0.41-21.el7.x86_64.rpm                                                                                                                                                 |  66 kB  00:00:00
(11/28): docker-scan-plugin-0.8.0-3.el7.x86_64.rpm                                                                                                                                        | 4.2 MB  00:00:00
(12/28): libnetfilter_conntrack-1.0.6-1.el7_3.x86_64.rpm                                                                                                                                  |  55 kB  00:00:00
(13/28): iptables-1.4.21-35.el7.x86_64.rpm                                                                                                                                                | 432 kB  00:00:00
(14/28): libseccomp-2.3.1-4.el7.x86_64.rpm                                                                                                                                                |  56 kB  00:00:00
(15/28): libmnl-1.0.3-7.el7.x86_64.rpm                                                                                                                                                    |  23 kB  00:00:00
(16/28): libselinux-python-2.5-15.el7.x86_64.rpm                                                                                                                                          | 236 kB  00:00:00
(17/28): libselinux-2.5-15.el7.x86_64.rpm                                                                                                                                                 | 162 kB  00:00:00
(18/28): libnfnetlink-1.0.1-4.el7.x86_64.rpm                                                                                                                                              |  26 kB  00:00:00
(19/28): libsemanage-python-2.5-14.el7.x86_64.rpm                                                                                                                                         | 113 kB  00:00:00
(20/28): libselinux-utils-2.5-15.el7.x86_64.rpm                                                                                                                                           | 151 kB  00:00:00
(21/28): python-IPy-0.75-6.el7.noarch.rpm                                                                                                                                                 |  32 kB  00:00:00
(22/28): policycoreutils-2.5-34.el7.x86_64.rpm                                                                                                                                            | 917 kB  00:00:00
(23/28): selinux-policy-3.13.1-268.el7_9.2.noarch.rpm                                                                                                                                     | 498 kB  00:00:00
(24/28): policycoreutils-python-2.5-34.el7.x86_64.rpm                                                                                                                                     | 457 kB  00:00:00
(25/28): docker-ce-cli-20.10.7-3.el7.x86_64.rpm                                                                                                                                           |  33 MB  00:00:02
(26/28): slirp4netns-0.4.3-4.el7_8.x86_64.rpm                                                                                                                                             |  81 kB  00:00:00
(27/28): selinux-policy-targeted-3.13.1-268.el7_9.2.noarch.rpm                                                                                                                            | 7.0 MB  00:00:00
(28/28): setools-libs-3.3.8-4.el7.x86_64.rpm                                                                                                                                              | 620 kB  00:00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                             27 MB/s | 114 MB  00:00:04
Retrieving key from https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 From       : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libselinux-2.5-15.el7.x86_64                                                                                                                                                                 1/30
  Installing : libseccomp-2.3.1-4.el7.x86_64                                                                                                                                                                2/30
  Installing : libselinux-utils-2.5-15.el7.x86_64                                                                                                                                                           3/30
  Installing : libcgroup-0.41-21.el7.x86_64                                                                                                                                                                 4/30
  Installing : libnfnetlink-1.0.1-4.el7.x86_64                                                                                                                                                              5/30
  Updating   : audit-libs-2.8.5-4.el7.x86_64                                                                                                                                                                6/30
  Installing : policycoreutils-2.5-34.el7.x86_64                                                                                                                                                            7/30
  Installing : selinux-policy-3.13.1-268.el7_9.2.noarch                                                                                                                                                     8/30
  Installing : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch                                                                                                                                            9/30
  Installing : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                                                                        10/30
  Installing : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                                                                                            11/30
  Installing : setools-libs-3.3.8-4.el7.x86_64                                                                                                                                                             12/30
  Installing : libselinux-python-2.5-15.el7.x86_64                                                                                                                                                         13/30
  Installing : 1:docker-ce-cli-20.10.7-3.el7.x86_64                                                                                                                                                        14/30
  Installing : docker-scan-plugin-0.8.0-3.el7.x86_64                                                                                                                                                       15/30
  Installing : libsemanage-python-2.5-14.el7.x86_64                                                                                                                                                        16/30
  Installing : fuse3-libs-3.6.1-4.el7.x86_64                                                                                                                                                               17/30
  Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                                                                                                         18/30
  Installing : python-IPy-0.75-6.el7.noarch                                                                                                                                                                19/30
  Installing : checkpolicy-2.5-8.el7.x86_64                                                                                                                                                                20/30
  Installing : policycoreutils-python-2.5-34.el7.x86_64                                                                                                                                                    21/30
  Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                                                          22/30
setsebool:  SELinux is disabled.
  Installing : containerd.io-1.4.8-3.1.el7.x86_64                                                                                                                                                          23/30
  Installing : libmnl-1.0.3-7.el7.x86_64                                                                                                                                                                   24/30
  Installing : libnetfilter_conntrack-1.0.6-1.el7_3.x86_64                                                                                                                                                 25/30
  Installing : iptables-1.4.21-35.el7.x86_64                                                                                                                                                               26/30
  Installing : docker-ce-rootless-extras-20.10.7-3.el7.x86_64                                                                                                                                              27/30
  Installing : 3:docker-ce-20.10.7-3.el7.x86_64                                                                                                                                                            28/30
  Cleanup    : audit-libs-2.8.4-4.el7.x86_64                                                                                                                                                               29/30
  Cleanup    : libselinux-2.5-14.1.el7.x86_64                                                                                                                                                              30/30
  Verifying  : libmnl-1.0.3-7.el7.x86_64                                                                                                                                                                    1/30
  Verifying  : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                                                                                                          2/30
  Verifying  : libselinux-2.5-15.el7.x86_64                                                                                                                                                                 3/30
  Verifying  : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                                                           4/30
  Verifying  : libnetfilter_conntrack-1.0.6-1.el7_3.x86_64                                                                                                                                                  5/30
  Verifying  : 3:docker-ce-20.10.7-3.el7.x86_64                                                                                                                                                             6/30
  Verifying  : selinux-policy-targeted-3.13.1-268.el7_9.2.noarch                                                                                                                                            7/30
  Verifying  : docker-ce-rootless-extras-20.10.7-3.el7.x86_64                                                                                                                                               8/30
  Verifying  : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                                                                         9/30
  Verifying  : audit-libs-2.8.5-4.el7.x86_64                                                                                                                                                               10/30
  Verifying  : checkpolicy-2.5-8.el7.x86_64                                                                                                                                                                11/30
  Verifying  : policycoreutils-2.5-34.el7.x86_64                                                                                                                                                           12/30
  Verifying  : python-IPy-0.75-6.el7.noarch                                                                                                                                                                13/30
  Verifying  : libseccomp-2.3.1-4.el7.x86_64                                                                                                                                                               14/30
  Verifying  : libselinux-utils-2.5-15.el7.x86_64                                                                                                                                                          15/30
  Verifying  : policycoreutils-python-2.5-34.el7.x86_64                                                                                                                                                    16/30
  Verifying  : setools-libs-3.3.8-4.el7.x86_64                                                                                                                                                             17/30
  Verifying  : fuse3-libs-3.6.1-4.el7.x86_64                                                                                                                                                               18/30
  Verifying  : docker-scan-plugin-0.8.0-3.el7.x86_64                                                                                                                                                       19/30
  Verifying  : libsemanage-python-2.5-14.el7.x86_64                                                                                                                                                        20/30
  Verifying  : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                                                                                            21/30
  Verifying  : libselinux-python-2.5-15.el7.x86_64                                                                                                                                                         22/30
  Verifying  : selinux-policy-3.13.1-268.el7_9.2.noarch                                                                                                                                                    23/30
  Verifying  : 1:docker-ce-cli-20.10.7-3.el7.x86_64                                                                                                                                                        24/30
  Verifying  : iptables-1.4.21-35.el7.x86_64                                                                                                                                                               25/30
  Verifying  : libnfnetlink-1.0.1-4.el7.x86_64                                                                                                                                                             26/30
  Verifying  : containerd.io-1.4.8-3.1.el7.x86_64                                                                                                                                                          27/30
  Verifying  : libcgroup-0.41-21.el7.x86_64                                                                                                                                                                28/30
  Verifying  : audit-libs-2.8.4-4.el7.x86_64                                                                                                                                                               29/30
  Verifying  : libselinux-2.5-14.1.el7.x86_64                                                                                                                                                              30/30

Installed:
  containerd.io.x86_64 0:1.4.8-3.1.el7                                  docker-ce.x86_64 3:20.10.7-3.el7                                  docker-ce-cli.x86_64 1:20.10.7-3.el7

Dependency Installed:
  audit-libs-python.x86_64 0:2.8.5-4.el7                 checkpolicy.x86_64 0:2.5-8.el7                container-selinux.noarch 2:2.119.2-1.911c772.el7_8    docker-ce-rootless-extras.x86_64 0:20.10.7-3.el7
  docker-scan-plugin.x86_64 0:0.8.0-3.el7                fuse-overlayfs.x86_64 0:0.7.2-6.el7_8         fuse3-libs.x86_64 0:3.6.1-4.el7                       iptables.x86_64 0:1.4.21-35.el7
  libcgroup.x86_64 0:0.41-21.el7                         libmnl.x86_64 0:1.0.3-7.el7                   libnetfilter_conntrack.x86_64 0:1.0.6-1.el7_3         libnfnetlink.x86_64 0:1.0.1-4.el7
  libseccomp.x86_64 0:2.3.1-4.el7                        libselinux-python.x86_64 0:2.5-15.el7         libselinux-utils.x86_64 0:2.5-15.el7                  libsemanage-python.x86_64 0:2.5-14.el7
  policycoreutils.x86_64 0:2.5-34.el7                    policycoreutils-python.x86_64 0:2.5-34.el7    python-IPy.noarch 0:0.75-6.el7                        selinux-policy.noarch 0:3.13.1-268.el7_9.2
  selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2    setools-libs.x86_64 0:3.3.8-4.el7             slirp4netns.x86_64 0:0.4.3-4.el7_8

Dependency Updated:
  audit-libs.x86_64 0:2.8.5-4.el7                                                                         libselinux.x86_64 0:2.5-15.el7

Complete!
列出可用版本
yum list docker-ce --showduplicates | sort -r
#执行结果
[root@DESKTOP-CHAI /]# yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64            3:20.10.7-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.1-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.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.1-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
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, ovl
Installed Packages
Available Packages
 * updates: mirrors.163.com
 * extras: mirrors.ustc.edu.cn
 * base: mirrors.ustc.edu.cn
选择需要安装的版本安装
#官方给出的安装命令
yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
#根据我们当先所拥有的版本选择
yum install docker-ce-20.10.7 docker-ce-cli-20.10.7 containerd.io
[root@DESKTOP-CHAI /]# yum install docker-ce-20.10.7 docker-ce-cli-20.10.7 containerd.io
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.163.com
Package 3:docker-ce-20.10.7-3.el7.x86_64 already installed and latest version
Package 1:docker-ce-cli-20.10.7-3.el7.x86_64 already installed and latest version
Package containerd.io-1.4.8-3.1.el7.x86_64 already installed and latest version
Nothing to do
Docker 已安装但未启动,启动docker
#启动docker
systemctl start docker
#添加docker开机自动启动
systemctl enable docker
#执行结果
[root@DESKTOP-CHAI-wsl ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

运行helloword
[root@desktop-chai-wsl ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:df5f5184104426b65967e016ff2ac0bfcd44ad7899ca3bbcf8e44e4461491a9e
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/
关闭docker-daemon
#停止docker
systemctl stop docker
#关闭开机自动启动docker
systemctl disable docker

3.卸载 Docker

卸载 Docker Engine、CLI 和 Containerd 包

yum remove docker-ce docker-ce-cli containerd.io

主机上的映像、容器、卷或自定义配置文件不会自动删除。删除所有镜像、容器和卷

rm -rf /var/lib/docker
rm -rf /var/lib/containerd
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

柴润泽

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值