首先明白什么是docker?docker到底有什么作用
Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从 Apache2.0 协议开源。Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级、可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口(类似 iPhone 的 app),更重要的是容器性能开销极低。
docker的组成?
docker是由镜像、容器、仓库组成
镜像(image):docker镜像就好比是一个目标,可以通过这个目标来创建容器服务,通过这个镜像可以创建多个容器==(最终服务运行或者项目运行就是在容器中的)。
容器(container):Docker利用容器技术,独立运行一个或者一组应用,通过镜像来创建的,目前就可以把这个容器理解为就是一个简易的 Linux系统。
仓库(repository):仓库就是存放镜像的地方,仓库分为共有仓库和私有仓库(很类似与git)
安装
1、环境准备
linux的内核要求要在3.0以上
[root@jmeter_1 ~]# uname -r 3.10.0-1062.el7.x86_64
2、卸载旧版本
1 yum remove docker \ 2 > docker-client \ 3 > docker-client-latest \ 4 > docker-common \ 5 > docker-latest \ 6 > docker-latest-logrotate \ 7 > docker-logrotate \ 8 > docker-engine 9 已加载插件:fastestmirror 10 参数 docker 没有匹配 11 参数 docker-client 没有匹配 12 参数 docker-client-latest 没有匹配 13 参数 docker-common 没有匹配 14 参数 docker-latest 没有匹配 15 参数 docker-latest-logrotate 没有匹配 16 参数 docker-logrotate 没有匹配 17 参数 docker-engine 没有匹配 18 不删除任何软件包
3、安装yum-utils
[root@localhost ~]# yum install -y yum-utils \ > device-mapper-persistent-data \ > lvm2 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.huaweicloud.com * extras: mirrors.huaweicloud.com * updates: mirrors.neusoft.edu.cn 软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本 正在解决依赖关系 --> 正在检查事务 ---> 软件包 device-mapper-persistent-data.x86_64.0.0.8.5-3.el7 将被 升级 ---> 软件包 device-mapper-persistent-data.x86_64.0.0.8.5-3.el7_9.2 将被 更新 ---> 软件包 lvm2.x86_64.7.2.02.187-6.el7 将被 升级 ---> 软件包 lvm2.x86_64.7.2.02.187-6.el7_9.4 将被 更新 --> 正在处理依赖关系 lvm2-libs = 7:2.02.187-6.el7_9.4,它被软件包 7:lvm2-2.02.187-6.el7_9.4.x86_64 需要 --> 正在检查事务 ---> 软件包 lvm2-libs.x86_64.7.2.02.187-6.el7 将被 升级 ---> 软件包 lvm2-libs.x86_64.7.2.02.187-6.el7_9.4 将被 更新 --> 正在处理依赖关系 device-mapper-event = 7:1.02.170-6.el7_9.4,它被软件包 7:lvm2-libs-2.02.187-6.el7_9.4.x86_64 需要 --> 正在检查事务 ---> 软件包 device-mapper-event.x86_64.7.1.02.170-6.el7 将被 升级 ---> 软件包 device-mapper-event.x86_64.7.1.02.170-6.el7_9.4 将被 更新 --> 正在处理依赖关系 device-mapper-event-libs = 7:1.02.170-6.el7_9.4,它被软件包 7:device-mapper-event-1.02.170-6.el7_9.4.x86_64 需要 --> 正在处理依赖关系 device-mapper = 7:1.02.170-6.el7_9.4,它被软件包 7:device-mapper-event-1.02.170-6.el7_9.4.x86_64 需要 --> 正在检查事务 ---> 软件包 device-mapper.x86_64.7.1.02.170-6.el7 将被 升级 --> 正在处理依赖关系 device-mapper = 7:1.02.170-6.el7,它被软件包 7:device-mapper-libs-1.02.170-6.el7.x86_64 需要 ---> 软件包 device-mapper.x86_64.7.1.02.170-6.el7_9.4 将被 更新 ---> 软件包 device-mapper-event-libs.x86_64.7.1.02.170-6.el7 将被 升级 ---> 软件包 device-mapper-event-libs.x86_64.7.1.02.170-6.el7_9.4 将被 更新 --> 正在检查事务 ---> 软件包 device-mapper-libs.x86_64.7.1.02.170-6.el7 将被 升级 ---> 软件包 device-mapper-libs.x86_64.7.1.02.170-6.el7_9.4 将被 更新 --> 解决依赖关系完成 依赖关系解决 ==================================================================================================================================== Package 架构 版本 源 大小 ==================================================================================================================================== 正在更新: device-mapper-persistent-data x86_64 0.8.5-3.el7_9.2 updates 423 k lvm2 x86_64 7:2.02.187-6.el7_9.4 updates 1.3 M 为依赖而更新: device-mapper x86_64 7:1.02.170-6.el7_9.4 updates 297 k device-mapper-event x86_64 7:1.02.170-6.el7_9.4 updates 192 k device-mapper-event-libs x86_64 7:1.02.170-6.el7_9.4 updates 192 k device-mapper-libs x86_64 7:1.02.170-6.el7_9.4 updates 325 k lvm2-libs x86_64 7:2.02.187-6.el7_9.4 updates 1.1 M 事务概要 ==================================================================================================================================== 升级 2 软件包 (+5 依赖软件包) 总下载量:3.8 M Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. (1/7): device-mapper-1.02.170-6.el7_9.4.x86_64.rpm | 297 kB 00:00:00 (2/7): device-mapper-event-1.02.170-6.el7_9.4.x86_64.rpm | 192 kB 00:00:00 (3/7): device-mapper-event-libs-1.02.170-6.el7_9.4.x86_64.rpm | 192 kB 00:00:00 (4/7): device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64.rpm | 423 kB 00:00:00 (5/7): device-mapper-libs-1.02.170-6.el7_9.4.x86_64.rpm | 325 kB 00:00:00 (6/7): lvm2-2.02.187-6.el7_9.4.x86_64.rpm | 1.3 MB 00:00:00 (7/7): lvm2-libs-2.02.187-6.el7_9.4.x86_64.rpm | 1.1 MB 00:00:00 ------------------------------------------------------------------------------------------------------------------------------------ 总计 7.3 MB/s | 3.8 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在更新 : 7:device-mapper-1.02.170-6.el7_9.4.x86_64 1/14 正在更新 : 7:device-mapper-libs-1.02.170-6.el7_9.4.x86_64 2/14 正在更新 : 7:device-mapper-event-libs-1.02.170-6.el7_9.4.x86_64 3/14 正在更新 : 7:device-mapper-event-1.02.170-6.el7_9.4.x86_64 4/14 正在更新 : 7:lvm2-libs-2.02.187-6.el7_9.4.x86_64 5/14 正在更新 : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 6/14 正在更新 : 7:lvm2-2.02.187-6.el7_9.4.x86_64 7/14 清理 : 7:lvm2-2.02.187-6.el7.x86_64 8/14 清理 : 7:lvm2-libs-2.02.187-6.el7.x86_64 9/14 清理 : 7:device-mapper-event-1.02.170-6.el7.x86_64 10/14 清理 : 7:device-mapper-event-libs-1.02.170-6.el7.x86_64 11/14 清理 : 7:device-mapper-1.02.170-6.el7.x86_64 12/14 清理 : 7:device-mapper-libs-1.02.170-6.el7.x86_64 13/14 清理 : device-mapper-persistent-data-0.8.5-3.el7.x86_64 14/14 验证中 : 7:lvm2-libs-2.02.187-6.el7_9.4.x86_64 1/14 验证中 : 7:device-mapper-libs-1.02.170-6.el7_9.4.x86_64 2/14 验证中 : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 3/14 验证中 : 7:device-mapper-event-libs-1.02.170-6.el7_9.4.x86_64 4/14 验证中 : 7:lvm2-2.02.187-6.el7_9.4.x86_64 5/14 验证中 : 7:device-mapper-event-1.02.170-6.el7_9.4.x86_64 6/14 验证中 : 7:device-mapper-1.02.170-6.el7_9.4.x86_64 7/14 验证中 : 7:device-mapper-event-libs-1.02.170-6.el7.x86_64 8/14 验证中 : 7:lvm2-libs-2.02.187-6.el7.x86_64 9/14 验证中 : 7:device-mapper-libs-1.02.170-6.el7.x86_64 10/14 验证中 : 7:lvm2-2.02.187-6.el7.x86_64 11/14 验证中 : device-mapper-persistent-data-0.8.5-3.el7.x86_64 12/14 验证中 : 7:device-mapper-event-1.02.170-6.el7.x86_64 13/14 验证中 : 7:device-mapper-1.02.170-6.el7.x86_64 14/14 更新完毕: device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2 lvm2.x86_64 7:2.02.187-6.el7_9.4 作为依赖被升级: device-mapper.x86_64 7:1.02.170-6.el7_9.4 device-mapper-event.x86_64 7:1.02.170-6.el7_9.4 device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.4 device-mapper-libs.x86_64 7:1.02.170-6.el7_9.4 lvm2-libs.x86_64 7:2.02.187-6.el7_9.4 完毕!
4、设置镜像的仓库,这里记住我们要设置国内的源,比如:阿里云
1 [root@jmeter_1 ~]# yum-config-manager \ 2 > --add-repo \ 3 > https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 4 已加载插件:fastestmirror 5 adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 6 grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo 7 repo saved to /etc/yum.repos.d/docker-ce.repo
5、更新yum软件包索引
1 [root@jmeter_1 ~]# yum-config-manager \ 2 > --add-repo \ 3 > https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 4 已加载插件:fastestmirror 5 adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 6 grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo 7 repo saved to /etc/yum.repos.d/docker-ce.repo 8 [root@jmeter_1 ~]# ^C 9 [root@jmeter_1 ~]# yum makecache fast 10 已加载插件:fastestmirror 11 Loading mirror speeds from cached hostfile 12 * base: mirrors.163.com 13 * extras: mirrors.aliyun.com 14 * updates: mirrors.aliyun.com 15 base | 3.6 kB 00:00:00 16 docker-ce-stable | 3.5 kB 00:00:00 17 extras | 2.9 kB 00:00:00 18 updates | 2.9 kB 00:00:00 19 (1/2): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00 20 (2/2): docker-ce-stable/7/x86_64/primary_db | 60 kB 00:00:02 21 元数据缓存已建立
6、安装docker相关的 docker-ce 社区版
1 [root@jmeter_1 ~]# yum install docker-ce docker-ce-cli containerd.io 2 已加载插件:fastestmirror 3 Loading mirror speeds from cached hostfile 4 * base: mirrors.163.com 5 * extras: mirrors.aliyun.com 6 * updates: mirrors.aliyun.com 7 正在解决依赖关系 8 --> 正在检查事务 9 ---> 软件包 containerd.io.x86_64.0.1.4.4-3.1.el7 将被 安装 10 --> 正在处理依赖关系 container-selinux >= 2:2.74,它被软件包 containerd.io-1.4.4-3.1.el7.x86_64 需要 11 ---> 软件包 docker-ce.x86_64.3.20.10.6-3.el7 将被 安装 12 --> 正在处理依赖关系 docker-ce-rootless-extras,它被软件包 3:docker-ce-20.10.6-3.el7.x86_64 需要 13 --> 正在处理依赖关系 libcgroup,它被软件包 3:docker-ce-20.10.6-3.el7.x86_64 需要 14 ---> 软件包 docker-ce-cli.x86_64.1.20.10.6-3.el7 将被 安装 15 --> 正在处理依赖关系 docker-scan-plugin(x86-64),它被软件包 1:docker-ce-cli-20.10.6-3.el7.x86_64 需要 16 --> 正在检查事务 17 ---> 软件包 container-selinux.noarch.2.2.119.2-1.911c772.el7_8 将被 安装 18 --> 正在处理依赖关系 policycoreutils-python,它被软件包 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 需要 19 ---> 软件包 docker-ce-rootless-extras.x86_64.0.20.10.6-3.el7 将被 安装 20 --> 正在处理依赖关系 fuse-overlayfs >= 0.7,它被软件包 docker-ce-rootless-extras-20.10.6-3.el7.x86_64 需要 21 --> 正在处理依赖关系 slirp4netns >= 0.4,它被软件包 docker-ce-rootless-extras-20.10.6-3.el7.x86_64 需要 22 ---> 软件包 docker-scan-plugin.x86_64.0.0.7.0-3.el7 将被 安装 23 ---> 软件包 libcgroup.x86_64.0.0.41-21.el7 将被 安装 24 --> 正在检查事务 25 ---> 软件包 fuse-overlayfs.x86_64.0.0.7.2-6.el7_8 将被 安装 26 --> 正在处理依赖关系 libfuse3.so.3(FUSE_3.2)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要 27 --> 正在处理依赖关系 libfuse3.so.3(FUSE_3.0)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要 28 --> 正在处理依赖关系 libfuse3.so.3()(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要 29 ---> 软件包 policycoreutils-python.x86_64.0.2.5-34.el7 将被 安装 30 --> 正在处理依赖关系 policycoreutils = 2.5-34.el7,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要 31 --> 正在处理依赖关系 setools-libs >= 3.3.8-4,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要 32 --> 正在处理依赖关系 libsemanage-python >= 2.5-14,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要 33 --> 正在处理依赖关系 audit-libs-python >= 2.1.3-4,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要 34 --> 正在处理依赖关系 python-IPy,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要 35 --> 正在处理依赖关系 libqpol.so.1(VERS_1.4)(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要 36 --> 正在处理依赖关系 libqpol.so.1(VERS_1.2)(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要 37 --> 正在处理依赖关系 libapol.so.4(VERS_4.0)(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要 38 --> 正在处理依赖关系 checkpolicy,它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要 39 --> 正在处理依赖关系 libqpol.so.1()(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要 40 --> 正在处理依赖关系 libapol.so.4()(64bit),它被软件包 policycoreutils-python-2.5-34.el7.x86_64 需要 41 ---> 软件包 slirp4netns.x86_64.0.0.4.3-4.el7_8 将被 安装 42 --> 正在检查事务 43 ---> 软件包 audit-libs-python.x86_64.0.2.8.5-4.el7 将被 安装 44 ---> 软件包 checkpolicy.x86_64.0.2.5-8.el7 将被 安装 45 ---> 软件包 fuse3-libs.x86_64.0.3.6.1-4.el7 将被 安装 46 ---> 软件包 libsemanage-python.x86_64.0.2.5-14.el7 将被 安装 47 ---> 软件包 policycoreutils.x86_64.0.2.5-33.el7 将被 升级 48 ---> 软件包 policycoreutils.x86_64.0.2.5-34.el7 将被 更新 49 ---> 软件包 python-IPy.noarch.0.0.75-6.el7 将被 安装 50 ---> 软件包 setools-libs.x86_64.0.3.3.8-4.el7 将被 安装 51 --> 解决依赖关系完成 52 53 依赖关系解决 54 55 ============================================================================================================================================================================================================================================= 56 Package 架构 版本 源 大小 57 ============================================================================================================================================================================================================================================= 58 正在安装: 59 containerd.io x86_64 1.4.4-3.1.el7 docker-ce-stable 33 M 60 docker-ce x86_64 3:20.10.6-3.el7 docker-ce-stable 27 M 61 docker-ce-cli x86_64 1:20.10.6-3.el7 docker-ce-stable 33 M 62 为依赖而安装: 63 audit-libs-python x86_64 2.8.5-4.el7 base 76 k 64 checkpolicy x86_64 2.5-8.el7 base 295 k 65 container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k 66 docker-ce-rootless-extras x86_64 20.10.6-3.el7 docker-ce-stable 9.2 M 67 docker-scan-plugin x86_64 0.7.0-3.el7 docker-ce-stable 4.2 M 68 fuse-overlayfs x86_64 0.7.2-6.el7_8 extras 54 k 69 fuse3-libs x86_64 3.6.1-4.el7 extras 82 k 70 libcgroup x86_64 0.41-21.el7 base 66 k 71 libsemanage-python x86_64 2.5-14.el7 base 113 k 72 policycoreutils-python x86_64 2.5-34.el7 base 457 k 73 python-IPy noarch 0.75-6.el7 base 32 k 74 setools-libs x86_64 3.3.8-4.el7 base 620 k 75 slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k 76 为依赖而更新: 77 policycoreutils x86_64 2.5-34.el7 base 917 k 78 79 事务概要 80 ============================================================================================================================================================================================================================================= 81 安装 3 软件包 (+13 依赖软件包) 82 升级 ( 1 依赖软件包) 83 84 总下载量:109 M 85 Is this ok [y/d/N]: y 86 Downloading packages: 87 Delta RPMs disabled because /usr/bin/applydeltarpm not installed. 88 (1/17): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00 89 (2/17): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00 90 (3/17): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00 91 warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/containerd.io-1.4.4-3.1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY ] 3.7 MB/s | 33 MB 00:00:20 ETA 92 containerd.io-1.4.4-3.1.el7.x86_64.rpm 的公钥尚未安装 93 (4/17): containerd.io-1.4.4-3.1.el7.x86_64.rpm | 33 MB 00:00:09 94 (5/17): docker-ce-cli-20.10.6-3.el7.x86_64.rpm | 33 MB 00:00:08 95 (6/17): docker-ce-rootless-extras-20.10.6-3.el7.x86_64.rpm | 9.2 MB 00:00:02 96 (7/17): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:00 97 (8/17): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00 98 (9/17): policycoreutils-2.5-34.el7.x86_64.rpm | 917 kB 00:00:00 99 (10/17): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:00 100 (11/17): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00 101 (12/17): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:00 102 (13/17): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00 103 (14/17): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00 104 (15/17): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00 105 (16/17): docker-scan-plugin-0.7.0-3.el7.x86_64.rpm | 4.2 MB 00:00:00 106 (17/17): docker-ce-20.10.6-3.el7.x86_64.rpm | 27 MB 00:04:58 107 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 108 总计 375 kB/s | 109 MB 00:04:58 109 从 https://download.docker.com/linux/centos/gpg 检索密钥 110 导入 GPG key 0x621E9F35: 111 用户ID : "Docker Release (CE rpm) <docker@docker.com>" 112 指纹 : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35 113 来自 : https://download.docker.com/linux/centos/gpg 114 是否继续?[y/N]:y 115 Running transaction check 116 Running transaction test 117 Transaction test succeeded 118 Running transaction 119 正在安装 : libcgroup-0.41-21.el7.x86_64 1/18 120 正在更新 : policycoreutils-2.5-34.el7.x86_64 2/18 121 正在安装 : 1:docker-ce-cli-20.10.6-3.el7.x86_64 3/18 122 正在安装 : docker-scan-plugin-0.7.0-3.el7.x86_64 4/18 123 正在安装 : audit-libs-python-2.8.5-4.el7.x86_64 5/18 124 正在安装 : setools-libs-3.3.8-4.el7.x86_64 6/18 125 正在安装 : checkpolicy-2.5-8.el7.x86_64 7/18 126 正在安装 : slirp4netns-0.4.3-4.el7_8.x86_64 8/18 127 正在安装 : python-IPy-0.75-6.el7.noarch 9/18 128 正在安装 : fuse3-libs-3.6.1-4.el7.x86_64 10/18 129 正在安装 : fuse-overlayfs-0.7.2-6.el7_8.x86_64 11/18 130 正在安装 : libsemanage-python-2.5-14.el7.x86_64 12/18 131 正在安装 : policycoreutils-python-2.5-34.el7.x86_64 13/18 132 正在安装 : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 14/18 133 正在安装 : containerd.io-1.4.4-3.1.el7.x86_64 15/18 134 正在安装 : docker-ce-rootless-extras-20.10.6-3.el7.x86_64 16/18 135 正在安装 : 3:docker-ce-20.10.6-3.el7.x86_64 17/18 136 清理 : policycoreutils-2.5-33.el7.x86_64 18/18 137 验证中 : libsemanage-python-2.5-14.el7.x86_64 1/18 138 验证中 : fuse3-libs-3.6.1-4.el7.x86_64 2/18 139 验证中 : python-IPy-0.75-6.el7.noarch 3/18 140 验证中 : docker-ce-rootless-extras-20.10.6-3.el7.x86_64 4/18 141 验证中 : fuse-overlayfs-0.7.2-6.el7_8.x86_64 5/18 142 验证中 : policycoreutils-python-2.5-34.el7.x86_64 6/18 143 验证中 : 3:docker-ce-20.10.6-3.el7.x86_64 7/18 144 验证中 : docker-scan-plugin-0.7.0-3.el7.x86_64 8/18 145 验证中 : slirp4netns-0.4.3-4.el7_8.x86_64 9/18 146 验证中 : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 10/18 147 验证中 : policycoreutils-2.5-34.el7.x86_64 11/18 148 验证中 : checkpolicy-2.5-8.el7.x86_64 12/18 149 验证中 : 1:docker-ce-cli-20.10.6-3.el7.x86_64 13/18 150 验证中 : containerd.io-1.4.4-3.1.el7.x86_64 14/18 151 验证中 : setools-libs-3.3.8-4.el7.x86_64 15/18 152 验证中 : audit-libs-python-2.8.5-4.el7.x86_64 16/18 153 验证中 : libcgroup-0.41-21.el7.x86_64 17/18 154 验证中 : policycoreutils-2.5-33.el7.x86_64 18/18 155 156 已安装: 157 containerd.io.x86_64 0:1.4.4-3.1.el7 docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-cli.x86_64 1:20.10.6-3.el7 158 159 作为依赖被安装: 160 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.6-3.el7 docker-scan-plugin.x86_64 0:0.7.0-3.el7 161 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7 libcgroup.x86_64 0:0.41-21.el7 libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils-python.x86_64 0:2.5-34.el7 162 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7 slirp4netns.x86_64 0:0.4.3-4.el7_8 163 164 作为依赖被升级: 165 policycoreutils.x86_64 0:2.5-34.el7 166 167 完毕!
7、启动docker
systemctl start docker
8、使用docker version查看是否安装成功
[root@jmeter_1 ~]# docker version Client: Docker Engine - Community Version: 20.10.6 API version: 1.41 Go version: go1.13.15 Git commit: 370c289 Built: Fri Apr 9 22:45:33 2021 OS/Arch: linux/amd64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.6 API version: 1.41 (minimum version 1.12) Go version: go1.13.15 Git commit: 8728dd2 Built: Fri Apr 9 22:43:57 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
9、测试下
[root@jmeter_1 ~]# docker run hello-world # 命令 Unable to find image 'hello-world:latest' locally # 提示没有找到hello-world这个镜像 latest: Pulling from library/hello-world # 从仓库中下载hello-world镜像 b8dfde127a29: Pull complete Digest: sha256:f2266cbfc127c960fd30e76b7c792dc23b588c0db76233517e1891a4e357d519 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就安装成功了
那么上面最后一步有用到docker run,下面用一幅图解释天docker run的运行机制
卸载docker也记录下
1、卸载
yum remove docker-ce docker-ce-cli containerd.io
2、删除资源
rm -rf /var/lib/docker rm -rf /var/lib/containerd