1.查看系统环境
要求:64位操作系统,建议内核3.8以上,root账户操作。
查看系统版本:rpm -q centos-release
查看内核版本:uname -a
[root@centos64 /]# rpm -q centos-release centos-release-7-9.2009.0.el7.centos.x86_64 [root@centos64 /]# uname -a Linux centos64.com 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux [root@centos64 /]#
2.更新yum包(我这边时本地环境,其他环境请慎重操作)
更新:yum update
[root@centos64 /]# yum update 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.aliyun.com base | 3.6 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 updates/7/x86_64/primary_db | 12 MB 00:00:06 正在解决依赖关系 --> 正在检查事务 ---> 软件包 NetworkManager.x86_64.1.1.18.8-1.el7 将被 升级 ---> 软件包 NetworkManager.x86_64.1.1.18.8-2.el7_9 将被 更新 ---> 软件包 NetworkManager-adsl.x86_64.1.1.18.8-1.el7 将被 升级
后续要求确认,输入y确认即可。
3.安装相关软件包
yum-utils ;
device-mapper-persistent-data ;
lvm2 ;
[root@centos64 /]# yum install -y yum-utils device-mapper-persistent-data lvm2 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.aliyun.com 软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本 软件包 device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 已安装并且是最新版本 软件包 7:lvm2-2.02.187-6.el7_9.5.x86_64 已安装并且是最新版本 无须任何处理 [root@centos64 /]#
4.设置yum源
我这里选择阿里仓库:
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
查看仓库中的docker版本:
yum list docker-ce --showduplicates | sort -r
[root@centos64 /]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 已加载插件:fastestmirror, langpacks Bad id for repo: mirrors.aliyun.com_docker-ce_linux_centos_docker-ce.xn--repo()-mu8ig98h4l0hokj, byte = ( 60 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 [root@centos64 /]# yum list docker-ce --showduplicates | sort -r Bad id for repo: mirrors.aliyun.com_docker-ce_linux_centos_docker-ce.xn--repo()-mu8ig98h4l0hokj, byte = ( 60 已加载插件:fastestmirror, langpacks 可安装的软件包 * updates: mirrors.aliyun.com Loading mirror speeds from cached hostfile * extras: mirrors.163.com 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
5.安装docker
安装:yum install docker-ce-18.03.1.ce (请按需求自选版本)
启动docker服务:systemctl start docker
加入开机自启:systemctl enable docker
查看:docker -v
[root@centos64 /]# yum install docker-ce-18.03.1.ce 已加载插件:fastestmirror, langpacks Bad id for repo: mirrors.aliyun.com_docker-ce_linux_centos_docker-ce.xn--repo()-mu8ig98h4l0hokj, byte = ( 60 Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.aliyun.com 正在解决依赖关系 --> 正在检查事务 ---> 软件包 docker-ce.x86_64.0.18.03.1.ce-1.el7.centos 将被 安装 --> 正在处理依赖关系 container-selinux >= 2.9,它被软件包 docker-ce-18.03.1.ce-1.el7.centos.x86_64 需要 --> 正在处理依赖关系 pigz,它被软件包 docker-ce-18.03.1.ce-1.el7.centos.x86_64 需要 --> 正在检查事务 ---> 软件包 container-selinux.noarch.2.2.119.2-1.911c772.el7_8 将被 安装 ---> 软件包 pigz.x86_64.0.2.3.3-1.el7.centos 将被 安装 --> 解决依赖关系完成 依赖关系解决 ============================================================================================================== Package 架构 版本 源 大小 ============================================================================================================== 正在安装: docker-ce x86_64 18.03.1.ce-1.el7.centos docker-ce-stable 35 M 为依赖而安装: container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k pigz x86_64 2.3.3-1.el7.centos extras 68 k 事务概要 ============================================================================================================== 安装 1 软件包 (+2 依赖软件包) 总下载量:35 M 安装大小:35 M Is this ok [y/d/N]: y Downloading packages: (1/3): pigz-2.3.3-1.el7.centos.x86_64.rpm | 68 kB 00:00:00 (2/3): 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-18.03.1.ce-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm 的公钥尚未安装 (3/3): docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm | 35 MB 00:00:04 -------------------------------------------------------------------------------------------------------------- 总计 8.5 MB/s | 35 MB 00:00:04 从 https://mirrors.aliyun.com/docker-ce/linux/centos/gpg 检索密钥 导入 GPG key 0x621E9F35: 用户ID : "Docker Release (CE rpm)" 指纹 : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35 来自 : https://mirrors.aliyun.com/docker-ce/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/3 正在安装 : pigz-2.3.3-1.el7.centos.x86_64 2/3 正在安装 : docker-ce-18.03.1.ce-1.el7.centos.x86_64 3/3 验证中 : pigz-2.3.3-1.el7.centos.x86_64 1/3 验证中 : docker-ce-18.03.1.ce-1.el7.centos.x86_64 2/3 验证中 : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 3/3 已安装: docker-ce.x86_64 0:18.03.1.ce-1.el7.centos 作为依赖被安装: container-selinux.noarch 2:2.119.2-1.911c772.el7_8 pigz.x86_64 0:2.3.3-1.el7.centos 完毕! [root@centos64 /]# systemctl start docker [root@centos64 /]# systemctl enable docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. [root@centos64 /]# docker -v Docker version 18.03.1-ce, build 9ee9f40 [root@centos64 /]#



