您的位置:首页 > 运维架构 > Docker

还在为不知道如何安装Docker担心吗?

2019-06-29 13:02 162 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/Jackieonway/article/details/94039262

Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从Apache2.0协议开源。Docker 可以让开发者打包应用以及依赖包到一个轻量级、可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口,更重要的是容器性能开销极低。其官网是http://www.docker.com

一、安装Docker 和Docker Compose

yum intstall docker docker-compose


安装过程中会询问是否确认安装,需要输入y 来确认安装。
安装过程如下:

[root@localhost ~]# yum install docker docker-compose
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.lzu.edu.cn
* extras: mirror.lzu.edu.cn
* updates: mirror.lzu.edu.cn
base                                                                                                 | 3.6 kB  00:00:00
extras                                                                                               | 3.4 kB  00:00:00
updates                                                                                              | 3.4 kB  00:00:00
(1/4): base/7/x86_64/group_gz                                                                        | 166 kB  00:00:00
(2/4): extras/7/x86_64/primary_db                                                                    | 205 kB  00:00:00
(3/4): updates/7/x86_64/primary_db                                                                   | 6.4 MB  00:00:05
(4/4): base/7/x86_64/primary_db                                                                      | 6.0 MB  00:00:07
没有可用软件包 docker-compose。
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker.x86_64.2.1.13.1-96.gitb2f74b2.el7.centos 将被 安装
--> 正在处理依赖关系 docker-common = 2:1.13.1-96.gitb2f74b2.el7.centos,它被软件包 2:docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64 需要
--> 正在处理依赖关系 docker-client = 2:1.13.1-96.gitb2f74b2.el7.centos,它被软件包 2:docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64 需要
--> 正在处理依赖关系 subscription-manager-rhsm-certificates,它被软件包 2:docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 docker-client.x86_64.2.1.13.1-96.gitb2f74b2.el7.centos 将被 安装
---> 软件包 docker-common.x86_64.2.1.13.1-96.gitb2f74b2.el7.centos 将被 安装
--> 正在处理依赖关系 skopeo-containers >= 1:0.1.26-2,它被软件包 2:docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64 需要
--> 正在处理依赖关系 oci-umount >= 2:2.3.3-3,它被软件包 2:docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64 需要
--> 正在处理依赖关系 oci-systemd-hook >= 1:0.1.4-9,它被软件包 2:docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64 需要
--> 正在处理依赖关系 oci-register-machine >= 1:0-5.13,它被软件包 2:docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64 需要
--> 正在处理依赖关系 container-storage-setup >= 0.9.0-1,它被软件包 2:docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64 需要
--> 正在处理依赖关系 container-selinux >= 2:2.51-1,它被软件包 2:docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64 需要
--> 正在处理依赖关系 atomic-registries,它被软件包 2:docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64 需要
---> 软件包 subscription-manager-rhsm-certificates.x86_64.0.1.21.10-3.el7.centos 将被 安装
--> 正在检查事务
---> 软件包 atomic-registries.x86_64.1.1.22.1-26.gitb507039.el7.centos 将被 安装
--> 正在处理依赖关系 python-yaml,它被软件包 1:atomic-registries-1.22.1-26.gitb507039.el7.centos.x86_64 需要
--> 正在处理依赖关系 python-setuptools,它被软件包 1:atomic-registries-1.22.1-26.gitb507039.el7.centos.x86_64 需要
--> 正在处理依赖关系 python-pytoml,它被软件包 1:atomic-registries-1.22.1-26.gitb507039.el7.centos.x86_64 需要
---> 软件包 container-selinux.noarch.2.2.99-1.el7_6 将被 安装
--> 正在处理依赖关系 selinux-policy-targeted >= 3.13.1-216.el7,它被软件包 2:container-selinux-2.99-1.el7_6.noarch 需要
--> 正在处理依赖关系 selinux-policy-base >= 3.13.1-216.el7,它被软件包 2:container-selinux-2.99-1.el7_6.noarch 需要
--> 正在处理依赖关系 selinux-policy >= 3.13.1-216.el7,它被软件包 2:container-selinux-2.99-1.el7_6.noarch 需要
--> 正在处理依赖关系 policycoreutils-python,它被软件包 2:container-selinux-2.99-1.el7_6.noarch 需要
---> 软件包 container-storage-setup.noarch.0.0.11.0-2.git5eaf76c.el7 将被 安装
---> 软件包 containers-common.x86_64.1.0.1.35-2.git404c5bd.el7.centos 将被 安装
---> 软件包 oci-register-machine.x86_64.1.0-6.git2b44233.el7 将被 安装
---> 软件包 oci-systemd-hook.x86_64.1.0.2.0-1.git05e6923.el7_6 将被 安装
--> 正在处理依赖关系 libyajl.so.2()(64bit),它被软件包 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64 需要
---> 软件包 oci-umount.x86_64.2.2.3.4-2.git87f9237.el7 将被 安装
--> 正在检查事务
---> 软件包 PyYAML.x86_64.0.3.10-11.el7 将被 安装
--> 正在处理依赖关系 libyaml-0.so.2()(64bit),它被软件包 PyYAML-3.10-11.el7.x86_64 需要
---> 软件包 policycoreutils-python.x86_64.0.2.5-29.el7_6.1 将被 安装
--> 正在处理依赖关系 policycoreutils = 2.5-29.el7_6.1,它被软件包 policycoreutils-python-2.5-29.el7_6.1.x86_64 需要
--> 正在处理依赖关系 setools-libs >= 3.3.8-4,它被软件包 policycoreutils-python-2.5-29.el7_6.1.x86_64 需要
--> 正在处理依赖关系 libsemanage-python >= 2.5-14,它被软件包 policycoreutils-python-2.5-29.el7_6.1.x86_64 需要
--> 正在处理依赖关系 audit-libs-python >= 2.1.3-4,它被软件包 policycoreutils-python-2.5-29.el7_6.1.x86_64 需要
--> 正在处理依赖关系 python-IPy,它被软件包 policycoreutils-python-2.5-29.el7_6.1.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1(VERS_1.4)(64bit),它被软件包 policycoreutils-python-2.5-29.el7_6.1.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1(VERS_1.2)(64bit),它被软件包 policycoreutils-python-2.5-29.el7_6.1.x86_64 需要
--> 正在处理依赖关系 libcgroup,它被软件包 policycoreutils-python-2.5-29.el7_6.1.x86_64 需要
--> 正在处理依赖关系 libapol.so.4(VERS_4.0)(64bit),它被软件包 policycoreutils-python-2.5-29.el7_6.1.x86_64 需要
--> 正在处理依赖关系 checkpolicy,它被软件包 policycoreutils-python-2.5-29.el7_6.1.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1()(64bit),它被软件包 policycoreutils-python-2.5-29.el7_6.1.x86_64 需要
--> 正在处理依赖关系 libapol.s
3ff7
o.4()(64bit),它被软件包 policycoreutils-python-2.5-29.el7_6.1.x86_64 需要
---> 软件包 python-pytoml.noarch.0.0.1.14-1.git7dea353.el7 将被 安装
---> 软件包 python-setuptools.noarch.0.0.9.8-7.el7 将被 安装
--> 正在处理依赖关系 python-backports-ssl_match_hostname,它被软件包 python-setuptools-0.9.8-7.el7.noarch 需要
---> 软件包 selinux-policy.noarch.0.3.13.1-192.el7 将被 升级
---> 软件包 selinux-policy.noarch.0.3.13.1-229.el7_6.12 将被 更新
--> 正在处理依赖关系 libsemanage >= 2.5-13,它被软件包 selinux-policy-3.13.1-229.el7_6.12.noarch 需要
---> 软件包 selinux-policy-targeted.noarch.0.3.13.1-192.el7 将被 升级
---> 软件包 selinux-policy-targeted.noarch.0.3.13.1-229.el7_6.12 将被 更新
---> 软件包 yajl.x86_64.0.2.0.4-4.el7 将被 安装
--> 正在检查事务
---> 软件包 audit-libs-python.x86_64.0.2.8.4-4.el7 将被 安装
--> 正在处理依赖关系 audit-libs(x86-64) = 2.8.4-4.el7,它被软件包 audit-libs-python-2.8.4-4.el7.x86_64 需要
---> 软件包 checkpolicy.x86_64.0.2.5-8.el7 将被 安装
---> 软件包 libcgroup.x86_64.0.0.41-20.el7 将被 安装
---> 软件包 libsemanage.x86_64.0.2.5-11.el7 将被 升级
---> 软件包 libsemanage.x86_64.0.2.5-14.el7 将被 更新
--> 正在处理依赖关系 libsepol >= 2.5-10,它被软件包 libsemanage-2.5-14.el7.x86_64 需要
--> 正在处理依赖关系 libselinux >= 2.5-14,它被软件包 libsemanage-2.5-14.el7.x86_64 需要
---> 软件包 libsemanage-python.x86_64.0.2.5-14.el7 将被 安装
---> 软件包 libyaml.x86_64.0.0.1.4-11.el7_0 将被 安装
---> 软件包 policycoreutils.x86_64.0.2.5-22.el7 将被 升级
---> 软件包 policycoreutils.x86_64.0.2.5-29.el7_6.1 将被 更新
--> 正在处理依赖关系 libselinux-utils >= 2.5-14,它被软件包 policycoreutils-2.5-29.el7_6.1.x86_64 需要
---> 软件包 python-IPy.noarch.0.0.75-6.el7 将被 安装
---> 软件包 python-backports-ssl_match_hostname.noarch.0.3.5.0.1-1.el7 将被 安装
--> 正在处理依赖关系 python-ipaddress,它被软件包 python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 需要
--> 正在处理依赖关系 python-backports,它被软件包 python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 需要
---> 软件包 setools-libs.x86_64.0.3.3.8-4.el7 将被 安装
--> 正在检查事务
---> 软件包 audit-libs.x86_64.0.2.8.1-3.el7 将被 升级
--> 正在处理依赖关系 audit-libs(x86-64) = 2.8.1-3.el7,它被软件包 audit-2.8.1-3.el7.x86_64 需要
---> 软件包 audit-libs.x86_64.0.2.8.4-4.el7 将被 更新
---> 软件包 libselinux.x86_64.0.2.5-12.el7 将被 升级
--> 正在处理依赖关系 libselinux(x86-64) = 2.5-12.el7,它被软件包 libselinux-python-2.5-12.el7.x86_64 需要
---> 软件包 libselinux.x86_64.0.2.5-14.1.el7 将被 更新
---> 软件包 libselinux-utils.x86_64.0.2.5-12.el7 将被 升级
---> 软件包 libselinux-utils.x86_64.0.2.5-14.1.el7 将被 更新
---> 软件包 libsepol.x86_64.0.2.5-8.1.el7 将被 升级
---> 软件包 libsepol.x86_64.0.2.5-10.el7 将被 更新
---> 软件包 python-backports.x86_64.0.1.0-8.el7 将被 安装
---> 软件包 python-ipaddress.noarch.0.1.0.16-2.el7 将被 安装
--> 正在检查事务
---> 软件包 audit.x86_64.0.2.8.1-3.el7 将被 升级
---> 软件包 audit.x86_64.0.2.8.4-4.el7 将被 更新
---> 软件包 libselinux-python.x86_64.0.2.5-12.el7 将被 升级
---> 软件包 libselinux-python.x86_64.0.2.5-14.1.el7 将被 更新
--> 解决依赖关系完成

依赖关系解决

============================================================================================================================
Package                                       架构          版本                                      源              大小
============================================================================================================================
正在安装:
docker                                        x86_64        2:1.13.1-96.gitb2f74b2.el7.centos         extras          18 M
为依赖而安装:
PyYAML                                        x86_64        3.10-11.el7                               base           153 k
atomic-registries                             x86_64        1:1.22.1-26.gitb507039.el7.centos         extras          35 k
audit-libs-python                             x86_64        2.8.4-4.el7                               base            76 k
checkpolicy                                   x86_64        2.5-8.el7                                 base           295 k
container-selinux                             noarch        2:2.99-1.el7_6                            extras          39 k
container-storage-setup                       noarch        0.11.0-2.git5eaf76c.el7                   extras          35 k
containers-common                             x86_64        1:0.1.35-2.git404c5bd.el7.centos          extras          21 k
docker-client                                 x86_64        2:1.13.1-96.gitb2f74b2.el7.centos         extras         3.9 M
docker-common                                 x86_64        2:1.13.1-96.gitb2f74b2.el7.centos         extras          96 k
libcgroup                                     x86_64        0.41-20.el7                               base            66 k
libsemanage-python                            x86_64        2.5-14.el7                                base           113 k
libyaml                                       x86_64        0.1.4-11.el7_0                            base            55 k
oci-register-machine                          x86_64        1:0-6.git2b44233.el7                      extras         1.1 M
oci-systemd-hook                              x86_64        1:0.2.0-1.git05e6923.el7_6                extras          34 k
oci-umount                                    x86_64        2:2.3.4-2.git87f9237.el7                  extras          32 k
policycoreutils-python                        x86_64        2.5-29.el7_6.1                            updates        456 k
python-IPy                                    noarch        0.75-6.el7                                base            32 k
python-backports                              x86_64        1.0-8.el7                                 base           5.8 k
python-backports-ssl_match_hostname           noarch        3.5.0.1-1.el7                             base            13 k
python-ipaddress                              noarch        1.0.16-2.el7                              base            34 k
python-pytoml                                 noarch        0.1.14-1.git7dea353.el7                   extras          18 k
python-setuptools                             noarch        0.9.8-7.el7                               base           397 k
setools-libs                                  x86_64        3.3.8-4.el7                               base           620 k
subscription-manager-rhsm-certificates        x86_64        1.21.10-3.el7.centos                      updates        207 k
yajl                                          x86_64        2.0.4-4.el7                               base            39 k
为依赖而更新:
audit                                         x86_64        2.8.4-4.el7                               base           250 k
audit-libs                                    x86_64        2.8.4-4.el7                               base           100 k
libselinux                                    x86_64        2.5-14.1.el7                              base           162 k
libselinux-python                             x86_64        2.5-14.1.el7                              base           235 k
libselinux-utils                              x86_64        2.5-14.1.el7                              base           151 k
libsemanage                                   x86_64        2.5-14.el7                                base           151 k
libsepol                                      x86_64        2.5-10.el7                                base           297 k
policycoreutils                               x86_64        2.5-29.el7_6.1                            updates        916 k
selinux-policy                                noarch        3.13.1-229.el7_6.12                       updates        484 k
selinux-policy-targeted                       noarch        3.13.1-229.el7_6.12                       updates        6.9 M

事务概要
============================================================================================================================
安装  1 软件包 (+25 依赖软件包)
升级           ( 10 依赖软件包)

总下载量:35 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
警告:/var/cache/yum/x86_64/7/extras/packages/atomic-registries-1.22.1-26.gitb507039.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
atomic-registries-1.22.1-26.gitb507039.el7.centos.x86_64.rpm 的公钥尚未安装
(1/36): atomic-registries-1.22.1-26.gitb507039.el7.centos.x86_64.rpm                                 |  35 kB  00:00:00
PyYAML-3.10-11.el7.x86_64.rpm 的公钥尚未安装
(2/36): PyYAML-3.10-11.el7.x86_64.rpm                                                                | 153 kB  00:00:00
(3/36): audit-2.8.4-4.el7.x86_64.rpm                                                                 | 250 kB  00:00:00
(4/36): audit-libs-python-2.8.4-4.el7.x86_64.rpm                                                     |  76 kB  00:00:00
(5/36): container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch.rpm                                   |  35 kB  00:00:00
(6/36): container-selinux-2.99-1.el7_6.noarch.rpm                                                    |  39 kB  00:00:00
(7/36): containers-common-0.1.35-2.git404c5bd.el7.centos.x86_64.rpm                                  |  21 kB  00:00:00
(8/36): docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64.rpm                                     |  96 kB  00:00:00
(9/36): libcgroup-0.41-20.el7.x86_64.rpm                                                             |  66 kB  00:00:00
(10/36): checkpolicy-2.5-8.el7.x86_64.rpm                                                            | 295 kB  00:00:01
(11/36): libselinux-python-2.5-14.1.el7.x86_64.rpm                                                   | 235 kB  00:00:00
(12/36): libselinux-2.5-14.1.el7.x86_64.rpm                                                          | 162 kB  00:00:00
(13/36): libselinux-utils-2.5-14.1.el7.x86_64.rpm                                                    | 151 kB  00:00:00
(14/36): libsemanage-2.5-14.el7.x86_64.rpm                                                           | 151 kB  00:00:00
(15/36): libsemanage-python-2.5-14.el7.x86_64.rpm                                                    | 113 kB  00:00:00
(16/36): libyaml-0.1.4-11.el7_0.x86_64.rpm                                                           |  55 kB  00:00:00
(17/36): libsepol-2.5-10.el7.x86_64.rpm                                                              | 297 kB  00:00:00
(18/36): oci-register-machine-0-6.git2b44233.el7.x86_64.rpm                                          | 1.1 MB  00:00:01
(19/36): oci-umount-2.3.4-2.git87f9237.el7.x86_64.rpm                                                |  32 kB  00:00:00
policycoreutils-2.5-29.el7_6.1.x86_64.rpm 的公钥尚未安装========-                         ] 1.4 MB/s |  11 MB  00:00:16 ETA
(20/36): policycoreutils-2.5-29.el7_6.1.x86_64.rpm                                                   | 916 kB  00:00:01
(21/36): policycoreutils-python-2.5-29.el7_6.1.x86_64.rpm                                            | 456 kB  00:00:00
(22/36): docker-client-1.13.1-96.gitb2f74b2.el7.centos.x86_64.rpm                                    | 3.9 MB  00:00:06
(23/36): python-IPy-0.75-6.el7.noarch.rpm                                                            |  32 kB  00:00:00
(24/36): python-backports-1.0-8.el7.x86_64.rpm                                                       | 5.8 kB  00:00:00
(25/36): python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm                                |  13 kB  00:00:00
(26/36): python-ipaddress-1.0.16-2.el7.noarch.rpm                                                    |  34 kB  00:00:00
(27/36): python-pytoml-0.1.14-1.git7dea353.el7.noarch.rpm                                            |  18 kB  00:00:00
(28/36): python-setuptools-0.9.8-7.el7.noarch.rpm                                                    | 397 kB  00:00:00
(29/36): selinux-policy-3.13.1-229.el7_6.12.noarch.rpm                                               | 484 kB  00:00:00
(30/36): setools-libs-3.3.8-4.el7.x86_64.rpm                                                         | 620 kB  00:00:00
(31/36): docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64.rpm                                           |  18 MB  00:00:17
(32/36): yajl-2.0.4-4.el7.x86_64.rpm                                                                 |  39 kB  00:00:00
audit-libs-2.8.4-4.el7.x86_64. FAILED                                          ======     ] 1.3 MB/s |  30 MB  00:00:03 ETA
http://mirrors.njupt.edu.cn/centos/7.6.1810/os/x86_64/Packages/audit-libs-2.8.4-4.el7.x86_64.rpm: [Errno 14] HTTP Error 302 - Found
正在尝试其它镜像。
(33/36): audit-libs-2.8.4-4.el7.x86_64.rpm                                                           | 100 kB  00:00:00
(34/36): selinux-policy-targeted-3.13.1-229.el7_6.12.noarch.rpm                                      | 6.9 MB  00:00:15
oci-systemd-hook-0.2.0-1.git05 FAILED
http://mirrors.njupt.edu.cn/centos/7.6.1810/extras/x86_64/Packages/oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64.rpm: [Errno 14] HTTP Error 302 - Found
正在尝试其它镜像。
(35/36): oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64.rpm                                        |  34 kB  00:00:00
subscription-manager-rhsm-cert FAILED
http://mirrors.njupt.edu.cn/centos/7.6.1810/updates/x86_64/Packages/subscription-manager-rhsm-certificates-1.21.10-3.el7.centos.x86_64.rpm: [Errno 14] HTTP Error 302 - Found
正在尝试其它镜像。
(36/36): subscription-manager-rhsm-certificates-1.21.10-3.el7.centos.x86_64.rpm                      | 207 kB  00:00:00
----------------------------------------------------------------------------------------------------------------------------
总计                                                                                        1.1 MB/s |  35 MB  00:00:31
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
软件包     : centos-release-7-5.1804.el7.centos.x86_64 (@anaconda)
来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在更新    : libsepol-2.5-10.el7.x86_64                                                                             1/46
正在更新    : libselinux-2.5-14.1.el7.x86_64                                                                         2/46
正在更新    : audit-libs-2.8.4-4.el7.x86_64                                                                          3/46
正在更新    : libsemanage-2.5-14.el7.x86_64                                                                          4/46
正在更新    : libselinux-utils-2.5-14.1.el7.x86_64                                                                   5/46
正在更新    : policycoreutils-2.5-29.el7_6.1.x86_64                                                                  6/46
正在更新    : selinux-policy-3.13.1-229.el7_6.12.noarch                                                              7/46
正在安装    : yajl-2.0.4-4.el7.x86_64
4000
8/46
正在安装    : 2:oci-umount-2.3.4-2.git87f9237.el7.x86_64                                                             9/46
正在安装    : 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64                                                    10/46
正在更新    : selinux-policy-targeted-3.13.1-229.el7_6.12.noarch                                                    11/46
正在安装    : libsemanage-python-2.5-14.el7.x86_64                                                                  12/46
正在安装    : audit-libs-python-2.8.4-4.el7.x86_64                                                                  13/46
正在安装    : setools-libs-3.3.8-4.el7.x86_64                                                                       14/46
正在更新    : libselinux-python-2.5-14.1.el7.x86_64                                                                 15/46
正在安装    : python-ipaddress-1.0.16-2.el7.noarch                                                                  16/46
正在安装    : libyaml-0.1.4-11.el7_0.x86_64                                                                         17/46
正在安装    : PyYAML-3.10-11.el7.x86_64                                                                             18/46
正在安装    : python-backports-1.0-8.el7.x86_64                                                                     19/46
正在安装    : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch                                              20/46
正在安装    : python-setuptools-0.9.8-7.el7.noarch                                                                  21/46
正在安装    : 1:containers-common-0.1.35-2.git404c5bd.el7.centos.x86_64                                             22/46
正在安装    : checkpolicy-2.5-8.el7.x86_64                                                                          23/46
正在安装    : 1:oci-register-machine-0-6.git2b44233.el7.x86_64                                                      24/46
正在安装    : python-pytoml-0.1.14-1.git7dea353.el7.noarch                                                          25/46
正在安装    : 1:atomic-registries-1.22.1-26.gitb507039.el7.centos.x86_64                                            26/46
正在安装    : python-IPy-0.75-6.el7.noarch                                                                          27/46
正在安装    : subscription-manager-rhsm-certificates-1.21.10-3.el7.centos.x86_64                                    28/46
正在安装    : container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch                                                29/46
正在安装    : libcgroup-0.41-20.el7.x86_64                                                                          30/46
正在安装    : policycoreutils-python-2.5-29.el7_6.1.x86_64                                                          31/46
正在安装    : 2:container-selinux-2.99-1.el7_6.noarch                                                               32/46
正在安装    : 2:docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64                                                33/46
正在安装    : 2:docker-client-1.13.1-96.gitb2f74b2.el7.centos.x86_64                                                34/46
正在安装    : 2:docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64                                                       35/46
正在更新    : audit-2.8.4-4.el7.x86_64                                                                              36/46
清理        : selinux-policy-targeted-3.13.1-192.el7.noarch                                                         37/46
清理        : selinux-policy-3.13.1-192.el7.noarch                                                                  38/46
清理        : policycoreutils-2.5-22.el7.x86_64                                                                     39/46
清理        : libsemanage-2.5-11.el7.x86_64                                                                         40/46
清理        : libselinux-utils-2.5-12.el7.x86_64                                                                    41/46
清理        : libselinux-python-2.5-12.el7.x86_64                                                                   42/46
清理        : libselinux-2.5-12.el7.x86_64                                                                          43/46
清理        : audit-2.8.1-3.el7.x86_64                                                                              44/46
清理        : audit-libs-2.8.1-3.el7.x86_64                                                                         45/46
清理        : libsepol-2.5-8.1.el7.x86_64                                                                           46/46
验证中      : libcgroup-0.41-20.el7.x86_64                                                                           1/46
验证中      : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch                                               2/46
验证中      : 2:docker-client-1.13.1-96.gitb2f74b2.el7.centos.x86_64                                                 3/46
验证中      : container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch                                                 4/46
验证中      : python-setuptools-0.9.8-7.el7.noarch                                                                   5/46
验证中      : subscription-manager-rhsm-certificates-1.21.10-3.el7.centos.x86_64                                     6/46
验证中      : policycoreutils-python-2.5-29.el7_6.1.x86_64                                                           7/46
验证中      : 2:oci-umount-2.3.4-2.git87f9237.el7.x86_64                                                             8/46
验证中      : policycoreutils-2.5-29.el7_6.1.x86_64                                                                  9/46
验证中      : audit-libs-2.8.4-4.el7.x86_64                                                                         10/46
验证中      : audit-2.8.4-4.el7.x86_64                                                                              11/46
验证中      : python-IPy-0.75-6.el7.noarch                                                                          12/46
验证中      : 2:docker-common-1.13.1-96.gitb2f74b2.el7.centos.x86_64                                                13/46
验证中      : python-pytoml-0.1.14-1.git7dea353.el7.noarch                                                          14/46
验证中      : selinux-policy-3.13.1-229.el7_6.12.noarch                                                             15/46
验证中      : selinux-policy-targeted-3.13.1-229.el7_6.12.noarch                                                    16/46
验证中      : 2:docker-1.13.1-96.gitb2f74b2.el7.centos.x86_64                                                       17/46
验证中      : libsemanage-python-2.5-14.el7.x86_64                                                                  18/46
验证中      : 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64                                                    19/46
验证中      : setools-libs-3.3.8-4.el7.x86_64                                                                       20/46
验证中      : 1:oci-register-machine-0-6.git2b44233.el7.x86_64                                                      21/46
验证中      : libsemanage-2.5-14.el7.x86_64                                                                         22/46
验证中      : libsepol-2.5-10.el7.x86_64                                                                            23/46
验证中      : checkpolicy-2.5-8.el7.x86_64                                                                          24/46
验证中      : 1:containers-common-0.1.35-2.git404c5bd.el7.centos.x86_64                                             25/46
验证中      : python-backports-1.0-8.el7.x86_64                                                                     26/46
验证中      : yajl-2.0.4-4.el7.x86_64                                                                               27/46
验证中      : 1:atomic-registries-1.22.1-26.gitb507039.el7.centos.x86_64                                            28/46
验证中      : libselinux-python-2.5-14.1.el7.x86_64                                                                 29/46
验证中      : audit-libs-python-2.8.4-4.el7.x86_64                                                                  30/46
验证中      : libyaml-0.1.4-11.el7_0.x86_64                                                                         31/46
验证中      : libselinux-utils-2.5-14.1.el7.x86_64                                                                  32/46
验证中      : python-ipaddress-1.0.16-2.el7.noarch                                                                  33/46
验证中      : PyYAML-3.10-11.el7.x86_64                                                                             34/46
验证中      : 2:container-selinux-2.99-1.el7_6.noarch                                                               35/46
验证中      : libselinux-2.5-14.1.el7.x86_64                                                                        36/46
验证中      : libsemanage-2.5-11.el7.x86_64                                                                         37/46
验证中      : audit-libs-2.8.1-3.el7.x86_64                                                                         38/46
验证中      : policycoreutils-2.5-22.el7.x86_64                                                                     39/46
验证中      : selinux-policy-targeted-3.13.1-192.el7.noarch                                                         40/46
验证中      : audit-2.8.1-3.el7.x86_64                                                                              41/46
验证中      : libsepol-2.5-8.1.el7.x86_64                                                                           42/46
验证中      : selinux-policy-3.13.1-192.el7.noarch                                                                  43/46
验证中      : libselinux-2.5-12.el7.x86_64                                                                          44/46
验证中      : libselinux-python-2.5-12.el7.x86_64                                                                   45/46
验证中      : libselinux-utils-2.5-12.el7.x86_64                                                                    46/46

已安装:
docker.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos

作为依赖被安装:
PyYAML.x86_64 0:3.10-11.el7
atomic-registries.x86_64 1:1.22.1-26.gitb507039.el7.centos
audit-libs-python.x86_64 0:2.8.4-4.el7
checkpolicy.x86_64 0:2.5-8.el7
container-selinux.noarch 2:2.99-1.el7_6
container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7
containers-common.x86_64 1:0.1.35-2.git404c5bd.el7.centos
docker-client.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos
docker-common.x86_64 2:1.13.1-96.gitb2f74b2.el7.centos
libcgroup.x86_64 0:0.41-20.el7
libsemanage-python.x86_64 0:2.5-14.el7
libyaml.x86_64 0:0.1.4-11.el7_0
oci-register-machine.x86_64 1:0-6.git2b44233.el7
oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6
oci-umount.x86_64 2:2.3.4-2.git87f9237.el7
policycoreutils-python.x86_64 0:2.5-29.el7_6.1
python-IPy.noarch 0:0.75-6.el7
python-backports.x86_64 0:1.0-8.el7
python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7
python-ipaddress.noarch 0:1.0.16-2.el7
python-pytoml.noarch 0:0.1.14-1.git7dea353.el7
python-setuptools.noarch 0:0.9.8-7.el7
setools-libs.x86_64 0:3.3.8-4.el7
subscription-manager-rhsm-certificates.x86_64 0:1.21.10-3.el7.centos
yajl.x86_64 0:2.0.4-4.el7

作为依赖被升级:
audit.x86_64 0:2.8.4-4.el7                               audit-libs.x86_64 0:2.8.4-4.el7
libselinux.x86_64 0:2.5-14.1.el7                         libselinux-python.x86_64 0:2.5-14.1.el7
libselinux-utils.x86_64 0:2.5-14.1.el7                   libsemanage.x86_64 0:2.5-14.el7
libsepol.x86_64 0:2.5-10.el7                             policycoreutils.x86_64 0:2.5-29.el7_6.1
selinux-policy.noarch 0:3.13.1-229.el7_6.12              selinux-policy-targeted.noarch 0:3.13.1-229.el7_6.12

完毕!

安装完成之后使用如下命令启动Docker服务

systemctl start docker
#查询docker是否启动
ps -ef | grep docker

完整展示:

[root@localhost ~]# systemctl start docker
[root@localhost ~]# ps -ef | grep docker
root       2461      1  0 17:48 ?        00:00:00 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json --selinux-enabled --log-driver=journald --signature-verification=false --storage-driver overlay2
root       2466   2461  0 17:48 ?        00:00:00 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shimdocker-containerd-shim --runtime docker-runc --runtime-args --systemd-cgroup=true
root       2558   1501  0 17:50 pts/0    00:00:00 grep --color=auto docker
[root@localhost ~]#

二、系统启动停止Docker命令

如果服务器重启,或者Docker进程被意外干掉了怎么办呢?别担心,下面就教您如何开启和关闭Docker进程。

# 启动Docker命令
systemctl start docker

# 停止Docker命令
systemctl stop docker

# 重启Docker命令
systemctl restart docker

三、简单的使用Docker

Docker 的HelloWorld

# 拉取h
4000
ello-world镜像
docker pull hello-world
# 运行hello-world
docker run hello-world

执行命令以及结果

[root@localhost ~]# docker pull hello-world
Using default tag: latest
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
1b930d010525: Pull complete
Digest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8
Status: Downloaded newer image for docker.io/hello-world:latest
[root@localhost ~]# 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 pull hello-world : pull 表示拉取镜像, hello-world 表示拉取的镜像名,默认拉取的是latest版本

docker  run hello-world : run 表示运行镜像 ,hello-world 表示拉取的镜像名

四、小结

到这里CentOS 安装Docker已经安装完成,但是值得注意的一点是Docker运行的环境需要Linux的内核大于3.10.0,如果您不知道怎么查询内核版本,可以使用如下命令:

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

如果您的内核版本低于3.10.0,请使用 yum update 升级系统内核,但是这只是一个缓兵之计,更好的办法是换用很高版本的Linux发行版本,CentOS6的内核就小于3.10.0哦。如果使用的是Ubuntu等其他Linux系统,升级系统内核、启动和停止命令有些不同哦,这点一顶要注意。小伙伴们,你们知道如何安装Docker了吗?是不是很简单呢?

任何形式的转载都请联系作者Jackieonway获得授权并注明出处。
微信搜索"JackieOnWay"关注我们,第一时间获取最新技术文摘。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: