centos7通过yum安装docker

系统环境:CentOS Linux release 7.9.2009 (Core)

卸载旧版本

[root@ARL ~]# yum remove docker \
>                   docker-client \
>                   docker-client-latest \
>                   docker-common \
>                   docker-latest \
>                   docker-latest-logrotate \
>                   docker-logrotate \
>                   docker-engine
已加载插件:fastestmirror, langpacks
参数 docker 没有匹配
参数 docker-client 没有匹配
参数 docker-client-latest 没有匹配
参数 docker-common 没有匹配
参数 docker-latest 没有匹配
参数 docker-latest-logrotate 没有匹配
参数 docker-logrotate 没有匹配
参数 docker-engine 没有匹配
不删除任何软件包

安装需要的安装包yum-utils

[root@ARL ~]# yum install -y yum-utils
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本
无须任何处理

设置镜像仓库地址

使用阿里云镜像

[root@ARL ~]# yum-config-manager \
>   --add-repo \
>    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
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引擎

更新yum软件包索引

[root@ARL ~]# yum makecache fase 
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.aliyun.com
docker-ce-stable                                                                                                                                                                                                  | 3.5 kB  00:00:00     
(1/4): docker-ce-stable/7/x86_64/filelists_db                                                                                                                                                                     |  25 kB  00:00:01     
(2/4): docker-ce-stable/7/x86_64/primary_db                                                                                                                                                                       |  58 kB  00:00:00     
(3/4): docker-ce-stable/7/x86_64/updateinfo                                                                                                                                                                       |   55 B  00:00:01     
(4/4): docker-ce-stable/7/x86_64/other_db                                                                                                                                                                         | 118 kB  00:00:00     
(1/4): updates/7/x86_64/other_db                                                                                                                                                                                  | 517 kB  00:00:00     
(2/4): extras/7/x86_64/other_db                                                                                                                                                                                   | 137 kB  00:00:00     
(3/4): extras/7/x86_64/filelists_db                                                                                                                                                                               | 228 kB  00:00:00     
(4/4): base/7/x86_64/other_db                                                                                                                                                                                     | 2.6 MB  00:00:00     
元数据缓存已建立

docker社区、ee企业版 ce为社区版 官方推荐使用ce版,默认安装最新的docker
版本,也可以指定版本安装

[root@ARL ~]# yum install docker-ce docker-ce-cli containerd.io
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 containerd.io.x86_64.0.1.4.4-3.1.el7 将被 安装
--> 正在处理依赖关系 container-selinux >= 2:2.74,它被软件包 containerd.io-1.4.4-3.1.el7.x86_64 需要
---> 软件包 docker-ce.x86_64.3.20.10.5-3.el7 将被 安装
--> 正在处理依赖关系 docker-ce-rootless-extras,它被软件包 3:docker-ce-20.10.5-3.el7.x86_64 需要
---> 软件包 docker-ce-cli.x86_64.1.20.10.5-3.el7 将被 安装
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.119.2-1.911c772.el7_8 将被 安装
---> 软件包 docker-ce-rootless-extras.x86_64.0.20.10.5-3.el7 将被 安装
--> 正在处理依赖关系 fuse-overlayfs >= 0.7,它被软件包 docker-ce-rootless-extras-20.10.5-3.el7.x86_64 需要
--> 正在处理依赖关系 slirp4netns >= 0.4,它被软件包 docker-ce-rootless-extras-20.10.5-3.el7.x86_64 需要
--> 正在检查事务
---> 软件包 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                                                        架构                                        版本                                                             源                                                     大小
=========================================================================================================================================================================================================================================
正在安装:
 containerd.io                                                  x86_64                                      1.4.4-3.1.el7                                                    docker-ce-stable                                       33 M
 docker-ce                                                      x86_64                                      3:20.10.5-3.el7                                                  docker-ce-stable                                       27 M
 docker-ce-cli                                                  x86_64                                      1:20.10.5-3.el7                                                  docker-ce-stable                                       33 M
为依赖而安装:
 container-selinux                                              noarch                                      2:2.119.2-1.911c772.el7_8                                        extras                                                 40 k
 docker-ce-rootless-extras                                      x86_64                                      20.10.5-3.el7                                                    docker-ce-stable                                      9.1 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

事务概要
=========================================================================================================================================================================================================================================
安装  3 软件包 (+5 依赖软件包)

总下载量:102 M
安装大小:424 M
Is this ok [y/d/N]: y
Downloading packages:
(1/8): 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.5-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY========                                          ] 6.6 MB/s |  56 MB  00:00:07 ETA 
docker-ce-20.10.5-3.el7.x86_64.rpm 的公钥尚未安装
(2/8): docker-ce-20.10.5-3.el7.x86_64.rpm                                                                                                                                                                         |  27 MB  00:00:09     
(3/8): containerd.io-1.4.4-3.1.el7.x86_64.rpm                                                                                                                                                                     |  33 MB  00:00:09     
(4/8): fuse3-libs-3.6.1-4.el7.x86_64.rpm                                                                                                                                                                          |  82 kB  00:00:00     
(5/8): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm                                                                                                                                                                    |  54 kB  00:00:00     
(6/8): slirp4netns-0.4.3-4.el7_8.x86_64.rpm                                                                                                                                                                       |  81 kB  00:00:00     
(7/8): docker-ce-rootless-extras-20.10.5-3.el7.x86_64.rpm                                                                                                                                                         | 9.1 MB  00:00:02     
(8/8): docker-ce-cli-20.10.5-3.el7.x86_64.rpm                                                                                                                                                                     |  33 MB  00:00:07     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                                                                     5.9 MB/s | 102 MB  00:00:17     
从 https://download.docker.com/linux/centos/gpg 检索密钥
导入 GPG key 0x621E9F35:
 用户ID     : "Docker Release (CE rpm) <docker@docker.com>"
 指纹       : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 来自       : https://download.docker.com/linux/centos/gpg
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                                                                                   1/8 
  正在安装    : containerd.io-1.4.4-3.1.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 
  正在安装    : 1:docker-ce-cli-20.10.5-3.el7.x86_64                                                                                                                                                                                 6/8 
  正在安装    : docker-ce-rootless-extras-20.10.5-3.el7.x86_64                                                                                                                                                                       7/8 
  正在安装    : 3:docker-ce-20.10.5-3.el7.x86_64                                                                                                                                                                                     8/8 
  验证中      : 1:docker-ce-cli-20.10.5-3.el7.x86_64                                                                                                                                                                                 1/8 
  验证中      : fuse3-libs-3.6.1-4.el7.x86_64                                                                                                                                                                                        2/8 
  验证中      : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                                                                                                                                  3/8 
  验证中      : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                                                                                                                     4/8 
  验证中      : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                                                                                                                   5/8 
  验证中      : 3:docker-ce-20.10.5-3.el7.x86_64                                                                                                                                                                                     6/8 
  验证中      : docker-ce-rootless-extras-20.10.5-3.el7.x86_64                                                                                                                                                                       7/8 
  验证中      : containerd.io-1.4.4-3.1.el7.x86_64                                                                                                                                                                                   8/8 

已安装:
  containerd.io.x86_64 0:1.4.4-3.1.el7                                          docker-ce.x86_64 3:20.10.5-3.el7                                          docker-ce-cli.x86_64 1:20.10.5-3.el7                                         

作为依赖被安装:
  container-selinux.noarch 2:2.119.2-1.911c772.el7_8      docker-ce-rootless-extras.x86_64 0:20.10.5-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

[root@ARL ~]# systemctl start docker
[root@ARL ~]# 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
添加新评论