美文网首页
Centos 7.5 安装Docker

Centos 7.5 安装Docker

作者: 无罪的坏人 | 来源:发表于2019-03-11 10:22 被阅读0次

小白第一次接触Docker,网上找了好多教程,有很多都不行,找了好久找到一个靠谱的,所以自己记一下方便日后安装。
感谢云雀https://www.yuque.com/grasilife/docker/install-centos
官谢docker官方文档https://docs.docker.com/install/linux/docker-ce/centos/


1.安装之前注意下自己的操作系统的内核版本

[root@localhost ~]# uname -r
3.10.0-862.el7.x86_64

建议安装版本大于3.10,不要安装太老的centos版本!!


2.使用 yum 安装

[root@localhost ~]# sudo yum install -y yum-utils \
> device-mapper-persistent-data \
> lvm2
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirrors.nju.edu.cn
 * extras: mirrors.163.com
 * updates: centos.ustc.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): extras/7/x86_64/primary_db                                                                                     | 180 kB  00:00:00
(2/4): base/7/x86_64/primary_db                                                                                       | 6.0 MB  00:00:07
(3/4): base/7/x86_64/group_gz                                                                                         | 166 kB  00:00:15
(4/4): updates/7/x86_64/primary_db                                                                                    | 2.5 MB  00:00:18
Package device-mapper-persistent-data-0.7.3-3.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package lvm2.x86_64 7:2.02.177-4.el7 will be updated
---> Package lvm2.x86_64 7:2.02.180-10.el7_6.3 will be an update
--> Processing Dependency: lvm2-libs = 7:2.02.180-10.el7_6.3 for package: 7:lvm2-2.02.180-10.el7_6.3.x86_64
---> Package yum-utils.noarch 0:1.1.31-50.el7 will be installed
--> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-50.el7.noarch
--> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-50.el7.noarch
--> Running transaction check
---> Package libxml2-python.x86_64 0:2.9.1-6.el7_2.3 will be installed
---> Package lvm2-libs.x86_64 7:2.02.177-4.el7 will be updated
---> Package lvm2-libs.x86_64 7:2.02.180-10.el7_6.3 will be an update
--> Processing Dependency: device-mapper-event = 7:1.02.149-10.el7_6.3 for package: 7:lvm2-libs-2.02.180-10.el7_6.3.x86_64
---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
--> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch
--> Running transaction check
---> Package device-mapper-event.x86_64 7:1.02.146-4.el7 will be updated
---> Package device-mapper-event.x86_64 7:1.02.149-10.el7_6.3 will be an update
--> Processing Dependency: device-mapper-event-libs = 7:1.02.149-10.el7_6.3 for package: 7:device-mapper-event-1.02.149-10.el7_6.3.x86_64
--> Processing Dependency: device-mapper = 7:1.02.149-10.el7_6.3 for package: 7:device-mapper-event-1.02.149-10.el7_6.3.x86_64
---> Package python-chardet.noarch 0:2.2.1-1.el7_1 will be installed
--> Running transaction check
---> Package device-mapper.x86_64 7:1.02.146-4.el7 will be updated
--> Processing Dependency: device-mapper = 7:1.02.146-4.el7 for package: 7:device-mapper-libs-1.02.146-4.el7.x86_64
---> Package device-mapper.x86_64 7:1.02.149-10.el7_6.3 will be an update
---> Package device-mapper-event-libs.x86_64 7:1.02.146-4.el7 will be updated
---> Package device-mapper-event-libs.x86_64 7:1.02.149-10.el7_6.3 will be an update
--> Running transaction check
---> Package device-mapper-libs.x86_64 7:1.02.146-4.el7 will be updated
---> Package device-mapper-libs.x86_64 7:1.02.149-10.el7_6.3 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================
 Package                                    Arch                     Version                                 Repository                 Size
=============================================================================================================================================
Installing:
 yum-utils                                  noarch                   1.1.31-50.el7                           base                      121 k
Updating:
 lvm2                                       x86_64                   7:2.02.180-10.el7_6.3                   updates                   1.3 M
Installing for dependencies:
 libxml2-python                             x86_64                   2.9.1-6.el7_2.3                         base                      247 k
 python-chardet                             noarch                   2.2.1-1.el7_1                           base                      227 k
 python-kitchen                             noarch                   1.1.1-5.el7                             base                      267 k
Updating for dependencies:
 device-mapper                              x86_64                   7:1.02.149-10.el7_6.3                   updates                   292 k
 device-mapper-event                        x86_64                   7:1.02.149-10.el7_6.3                   updates                   188 k
 device-mapper-event-libs                   x86_64                   7:1.02.149-10.el7_6.3                   updates                   188 k
 device-mapper-libs                         x86_64                   7:1.02.149-10.el7_6.3                   updates                   320 k
 lvm2-libs                                  x86_64                   7:2.02.180-10.el7_6.3                   updates                   1.1 M

Transaction Summary
=============================================================================================================================================
Install  1 Package (+3 Dependent packages)
Upgrade  1 Package (+5 Dependent packages)

Total download size: 4.2 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/updates/packages/device-mapper-event-libs-1.02.149-10.el7_6.3.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for device-mapper-event-libs-1.02.149-10.el7_6.3.x86_64.rpm is not installed
(1/10): device-mapper-event-libs-1.02.149-10.el7_6.3.x86_64.rpm                                                       | 188 kB  00:00:00
(2/10): device-mapper-1.02.149-10.el7_6.3.x86_64.rpm                                                                  | 292 kB  00:00:01
(3/10): lvm2-libs-2.02.180-10.el7_6.3.x86_64.rpm                                                                      | 1.1 MB  00:00:02
(4/10): lvm2-2.02.180-10.el7_6.3.x86_64.rpm                                                                           | 1.3 MB  00:00:02
Public key for python-kitchen-1.1.1-5.el7.noarch.rpm is not installed=========================-            ] 703 kB/s | 3.1 MB  00:00:01 ETA
(5/10): python-kitchen-1.1.1-5.el7.noarch.rpm                                                                         | 267 kB  00:00:00
(6/10): yum-utils-1.1.31-50.el7.noarch.rpm                                                                            | 121 kB  00:00:00
(7/10): device-mapper-event-1.02.149-10.el7_6.3.x86_64.rpm                                                            | 188 kB  00:00:16
(8/10): libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm                                                                     | 247 kB  00:00:16
(9/10): device-mapper-libs-1.02.149-10.el7_6.3.x86_64.rpm                                                             | 320 kB  00:00:16
(10/10): python-chardet-2.2.1-1.el7_1.noarch.rpm                                                                      | 227 kB  00:00:15
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                        225 kB/s | 4.2 MB  00:00:19
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-5.1804.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : 7:device-mapper-1.02.149-10.el7_6.3.x86_64                                                                               1/16
  Updating   : 7:device-mapper-libs-1.02.149-10.el7_6.3.x86_64                                                                          2/16
  Updating   : 7:device-mapper-event-libs-1.02.149-10.el7_6.3.x86_64                                                                    3/16
  Updating   : 7:device-mapper-event-1.02.149-10.el7_6.3.x86_64                                                                         4/16
  Updating   : 7:lvm2-libs-2.02.180-10.el7_6.3.x86_64                                                                                   5/16
  Installing : python-chardet-2.2.1-1.el7_1.noarch                                                                                      6/16
  Installing : python-kitchen-1.1.1-5.el7.noarch                                                                                        7/16
  Installing : libxml2-python-2.9.1-6.el7_2.3.x86_64                                                                                    8/16
  Installing : yum-utils-1.1.31-50.el7.noarch                                                                                           9/16
  Updating   : 7:lvm2-2.02.180-10.el7_6.3.x86_64                                                                                       10/16
  Cleanup    : 7:lvm2-2.02.177-4.el7.x86_64                                                                                            11/16
  Cleanup    : 7:lvm2-libs-2.02.177-4.el7.x86_64                                                                                       12/16
  Cleanup    : 7:device-mapper-event-1.02.146-4.el7.x86_64                                                                             13/16
  Cleanup    : 7:device-mapper-event-libs-1.02.146-4.el7.x86_64                                                                        14/16
  Cleanup    : 7:device-mapper-1.02.146-4.el7.x86_64                                                                                   15/16
  Cleanup    : 7:device-mapper-libs-1.02.146-4.el7.x86_64                                                                              16/16
  Verifying  : yum-utils-1.1.31-50.el7.noarch                                                                                           1/16
  Verifying  : 7:device-mapper-libs-1.02.149-10.el7_6.3.x86_64                                                                          2/16
  Verifying  : libxml2-python-2.9.1-6.el7_2.3.x86_64                                                                                    3/16
  Verifying  : 7:device-mapper-event-libs-1.02.149-10.el7_6.3.x86_64                                                                    4/16
  Verifying  : python-chardet-2.2.1-1.el7_1.noarch                                                                                      5/16
  Verifying  : python-kitchen-1.1.1-5.el7.noarch                                                                                        6/16
  Verifying  : 7:device-mapper-event-1.02.149-10.el7_6.3.x86_64                                                                         7/16
  Verifying  : 7:lvm2-libs-2.02.180-10.el7_6.3.x86_64                                                                                   8/16
  Verifying  : 7:lvm2-2.02.180-10.el7_6.3.x86_64                                                                                        9/16
  Verifying  : 7:device-mapper-1.02.149-10.el7_6.3.x86_64                                                                              10/16
  Verifying  : 7:lvm2-2.02.177-4.el7.x86_64                                                                                            11/16
  Verifying  : 7:device-mapper-event-libs-1.02.146-4.el7.x86_64                                                                        12/16
  Verifying  : 7:device-mapper-1.02.146-4.el7.x86_64                                                                                   13/16
  Verifying  : 7:device-mapper-event-1.02.146-4.el7.x86_64                                                                             14/16
  Verifying  : 7:lvm2-libs-2.02.177-4.el7.x86_64                                                                                       15/16
  Verifying  : 7:device-mapper-libs-1.02.146-4.el7.x86_64                                                                              16/16

Installed:
  yum-utils.noarch 0:1.1.31-50.el7

Dependency Installed:
  libxml2-python.x86_64 0:2.9.1-6.el7_2.3         python-chardet.noarch 0:2.2.1-1.el7_1         python-kitchen.noarch 0:1.1.1-5.el7

Updated:
  lvm2.x86_64 7:2.02.180-10.el7_6.3

Dependency Updated:
  device-mapper.x86_64 7:1.02.149-10.el7_6.3                              device-mapper-event.x86_64 7:1.02.149-10.el7_6.3
  device-mapper-event-libs.x86_64 7:1.02.149-10.el7_6.3                   device-mapper-libs.x86_64 7:1.02.149-10.el7_6.3
  lvm2-libs.x86_64 7:2.02.180-10.el7_6.3

Complete!

看到compkete就表示已经好了!

鉴于国内网络问题,强烈建议使用国内源,官方源请在注释中查看。

执行下面的命令添加 yum 软件源:

[root@localhost ~]# sudo yum-config-manager \
> --add-repo \
> http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
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

这里的源换一下,换成阿里云的!


3.安装 Docker CE

更新 yum 软件源缓存,并安装 docker-ce。

[root@localhost ~]# yum makecache fast
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
base                                                                                                                  | 3.6 kB  00:00:00
docker-ce-stable                                                                                                      | 3.5 kB  00:00:00
extras                                                                                                                | 3.4 kB  00:00:00
updates                                                                                                               | 3.4 kB  00:00:00
(1/2): docker-ce-stable/x86_64/updateinfo                                                                             |   55 B  00:00:00
(2/2): docker-ce-stable/x86_64/primary_db                                                                             |  25 kB  00:00:00
Metadata Cache Created

开始安装啦!

[root@localhost ~]# yum -y install docker-ce
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.shu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:18.09.3-3.el7 will be installed
--> Processing Dependency: container-selinux >= 2.9 for package: 3:docker-ce-18.09.3-3.el7.x86_64
--> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-18.09.3-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-18.09.3-3.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-18.09.3-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.74-1.el7 will be installed
--> Processing Dependency: selinux-policy-targeted >= 3.13.1-216.el7 for package: 2:container-selinux-2.74-1.el7.noarch
--> Processing Dependency: selinux-policy-base >= 3.13.1-216.el7 for package: 2:container-selinux-2.74-1.el7.noarch
--> Processing Dependency: selinux-policy >= 3.13.1-216.el7 for package: 2:container-selinux-2.74-1.el7.noarch
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.74-1.el7.noarch
---> Package containerd.io.x86_64 0:1.2.4-3.1.el7 will be installed
---> Package docker-ce-cli.x86_64 1:18.09.3-3.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-20.el7 will be installed
--> Running transaction check
---> Package policycoreutils-python.x86_64 0:2.5-29.el7_6.1 will be installed
--> Processing Dependency: policycoreutils = 2.5-29.el7_6.1 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
---> Package selinux-policy.noarch 0:3.13.1-192.el7 will be updated
---> Package selinux-policy.noarch 0:3.13.1-229.el7_6.9 will be an update
--> Processing Dependency: libsemanage >= 2.5-13 for package: selinux-policy-3.13.1-229.el7_6.9.noarch
---> Package selinux-policy-targeted.noarch 0:3.13.1-192.el7 will be updated
---> Package selinux-policy-targeted.noarch 0:3.13.1-229.el7_6.9 will be an update
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.4-4.el7 will be installed
--> Processing Dependency: audit-libs(x86-64) = 2.8.4-4.el7 for package: audit-libs-python-2.8.4-4.el7.x86_64
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package libsemanage.x86_64 0:2.5-11.el7 will be updated
---> Package libsemanage.x86_64 0:2.5-14.el7 will be an update
--> Processing Dependency: libsepol >= 2.5-10 for package: libsemanage-2.5-14.el7.x86_64
--> Processing Dependency: libselinux >= 2.5-14 for package: libsemanage-2.5-14.el7.x86_64
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package policycoreutils.x86_64 0:2.5-22.el7 will be updated
---> Package policycoreutils.x86_64 0:2.5-29.el7_6.1 will be an update
--> Processing Dependency: libselinux-utils >= 2.5-14 for package: policycoreutils-2.5-29.el7_6.1.x86_64
---> 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.1-3.el7 will be updated
--> Processing Dependency: audit-libs(x86-64) = 2.8.1-3.el7 for package: audit-2.8.1-3.el7.x86_64
---> Package audit-libs.x86_64 0:2.8.4-4.el7 will be an update
---> Package libselinux.x86_64 0:2.5-12.el7 will be updated
--> Processing Dependency: libselinux(x86-64) = 2.5-12.el7 for package: libselinux-python-2.5-12.el7.x86_64
---> Package libselinux.x86_64 0:2.5-14.1.el7 will be an update
---> Package libselinux-utils.x86_64 0:2.5-12.el7 will be updated
---> Package libselinux-utils.x86_64 0:2.5-14.1.el7 will be an update
---> Package libsepol.x86_64 0:2.5-8.1.el7 will be updated
---> Package libsepol.x86_64 0:2.5-10.el7 will be an update
--> Running transaction check
---> Package audit.x86_64 0:2.8.1-3.el7 will be updated
---> Package audit.x86_64 0:2.8.4-4.el7 will be an update
---> Package libselinux-python.x86_64 0:2.5-12.el7 will be updated
---> Package libselinux-python.x86_64 0:2.5-14.1.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================
 Package                                 Arch                   Version                               Repository                        Size
=============================================================================================================================================
Installing:
 docker-ce                               x86_64                 3:18.09.3-3.el7                       docker-ce-stable                  19 M
Installing for dependencies:
 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.74-1.el7                          extras                            38 k
 containerd.io                           x86_64                 1.2.4-3.1.el7                         docker-ce-stable                  22 M
 docker-ce-cli                           x86_64                 1:18.09.3-3.el7                       docker-ce-stable                  14 M
 libcgroup                               x86_64                 0.41-20.el7                           base                              66 k
 libsemanage-python                      x86_64                 2.5-14.el7                            base                             113 k
 policycoreutils-python                  x86_64                 2.5-29.el7_6.1                        updates                          456 k
 python-IPy                              noarch                 0.75-6.el7                            base                              32 k
 setools-libs                            x86_64                 3.3.8-4.el7                           base                             620 k
Updating for dependencies:
 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.9                    updates                          483 k
 selinux-policy-targeted                 noarch                 3.13.1-229.el7_6.9                    updates                          6.9 M

Transaction Summary
=============================================================================================================================================
Install  1 Package  (+10 Dependent packages)
Upgrade             ( 10 Dependent packages)

Total download size: 66 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/21): audit-libs-2.8.4-4.el7.x86_64.rpm                                                                             | 100 kB  00:00:00
(2/21): container-selinux-2.74-1.el7.noarch.rpm                                                                       |  38 kB  00:00:00
(3/21): checkpolicy-2.5-8.el7.x86_64.rpm                                                                              | 295 kB  00:00:00
(4/21): audit-2.8.4-4.el7.x86_64.rpm                                                                                  | 250 kB  00:00:01
(5/21): audit-libs-python-2.8.4-4.el7.x86_64.rpm                                                                      |  76 kB  00:00:16
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-18.09.3-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-18.09.3-3.el7.x86_64.rpm is not installed
(6/21): docker-ce-18.09.3-3.el7.x86_64.rpm                                                                            |  19 MB  00:00:38
(7/21): libcgroup-0.41-20.el7.x86_64.rpm                                                                              |  66 kB  00:00:00
(8/21): libselinux-2.5-14.1.el7.x86_64.rpm                                                                            | 162 kB  00:00:01
(9/21): libselinux-utils-2.5-14.1.el7.x86_64.rpm                                                                      | 151 kB  00:00:01
(10/21): libsemanage-python-2.5-14.el7.x86_64.rpm                                                                     | 113 kB  00:00:00
(11/21): libsepol-2.5-10.el7.x86_64.rpm                                                                               | 297 kB  00:00:00
(12/21): libsemanage-2.5-14.el7.x86_64.rpm                                                                            | 151 kB  00:00:01
(13/21): containerd.io-1.2.4-3.1.el7.x86_64.rpm                                                                       |  22 MB  00:00:47
(14/21): python-IPy-0.75-6.el7.noarch.rpm                                                                             |  32 kB  00:00:00
(15/21): libselinux-python-2.5-14.1.el7.x86_64.rpm                                                                    | 235 kB  00:00:17
(16/21): policycoreutils-python-2.5-29.el7_6.1.x86_64.rpm                                                             | 456 kB  00:00:15
(17/21): setools-libs-3.3.8-4.el7.x86_64.rpm                                                                          | 620 kB  00:00:02
(18/21): policycoreutils-2.5-29.el7_6.1.x86_64.rpm                                                                    | 916 kB  00:00:18
(19/21): docker-ce-cli-18.09.3-3.el7.x86_64.rpm                                                                       |  14 MB  00:00:21
(20/21): selinux-policy-targeted-3.13.1-229.el7_6.9.noarch.rpm                                                        | 6.9 MB  00:00:10
selinux-policy-3.13.1-229.el7_ FAILED                                          ===========================-] 1.0 kB/s |  66 MB  00:02:57 ETA
http://mirror.lzu.edu.cn/centos/7.6.1810/updates/x86_64/Packages/selinux-policy-3.13.1-229.el7_6.9.noarch.rpm: [Errno 12] Timeout on http://mirror.lzu.edu.cn/centos/7.6.1810/updates/x86_64/Packages/selinux-policy-3.13.1-229.el7_6.9.noarch.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(21/21): selinux-policy-3.13.1-229.el7_6.9.noarch.rpm                                                                 | 483 kB  00:00:15
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                        595 kB/s |  66 MB  00:01:53
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
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libsepol-2.5-10.el7.x86_64                                                                                               1/31
  Updating   : libselinux-2.5-14.1.el7.x86_64                                                                                           2/31
  Updating   : audit-libs-2.8.4-4.el7.x86_64                                                                                            3/31
  Updating   : libsemanage-2.5-14.el7.x86_64                                                                                            4/31
  Updating   : libselinux-utils-2.5-14.1.el7.x86_64                                                                                     5/31
  Updating   : policycoreutils-2.5-29.el7_6.1.x86_64                                                                                    6/31
  Updating   : selinux-policy-3.13.1-229.el7_6.9.noarch                                                                                 7/31
  Installing : libcgroup-0.41-20.el7.x86_64                                                                                             8/31
  Updating   : selinux-policy-targeted-3.13.1-229.el7_6.9.noarch                                                                        9/31
  Installing : libsemanage-python-2.5-14.el7.x86_64                                                                                    10/31
  Installing : audit-libs-python-2.8.4-4.el7.x86_64                                                                                    11/31
  Installing : setools-libs-3.3.8-4.el7.x86_64                                                                                         12/31
  Updating   : libselinux-python-2.5-14.1.el7.x86_64                                                                                   13/31
  Installing : containerd.io-1.2.4-3.1.el7.x86_64                                                                                      14/31
  Installing : 1:docker-ce-cli-18.09.3-3.el7.x86_64                                                                                    15/31
  Installing : python-IPy-0.75-6.el7.noarch                                                                                            16/31
  Installing : checkpolicy-2.5-8.el7.x86_64                                                                                            17/31
  Installing : policycoreutils-python-2.5-29.el7_6.1.x86_64                                                                            18/31
  Installing : 2:container-selinux-2.74-1.el7.noarch                                                                                   19/31
  Installing : 3:docker-ce-18.09.3-3.el7.x86_64                                                                                        20/31
  Updating   : audit-2.8.4-4.el7.x86_64                                                                                                21/31
  Cleanup    : selinux-policy-targeted-3.13.1-192.el7.noarch                                                                           22/31
  Cleanup    : selinux-policy-3.13.1-192.el7.noarch                                                                                    23/31
  Cleanup    : policycoreutils-2.5-22.el7.x86_64                                                                                       24/31
  Cleanup    : libsemanage-2.5-11.el7.x86_64                                                                                           25/31
  Cleanup    : libselinux-utils-2.5-12.el7.x86_64                                                                                      26/31
  Cleanup    : libselinux-python-2.5-12.el7.x86_64                                                                                     27/31
  Cleanup    : libselinux-2.5-12.el7.x86_64                                                                                            28/31
  Cleanup    : audit-2.8.1-3.el7.x86_64                                                                                                29/31
  Cleanup    : audit-libs-2.8.1-3.el7.x86_64                                                                                           30/31
  Cleanup    : libsepol-2.5-8.1.el7.x86_64                                                                                             31/31
  Verifying  : libcgroup-0.41-20.el7.x86_64                                                                                             1/31
  Verifying  : 2:container-selinux-2.74-1.el7.noarch                                                                                    2/31
  Verifying  : policycoreutils-2.5-29.el7_6.1.x86_64                                                                                    3/31
  Verifying  : checkpolicy-2.5-8.el7.x86_64                                                                                             4/31
  Verifying  : audit-libs-2.8.4-4.el7.x86_64                                                                                            5/31
  Verifying  : audit-2.8.4-4.el7.x86_64                                                                                                 6/31
  Verifying  : python-IPy-0.75-6.el7.noarch                                                                                             7/31
  Verifying  : setools-libs-3.3.8-4.el7.x86_64                                                                                          8/31
  Verifying  : policycoreutils-python-2.5-29.el7_6.1.x86_64                                                                             9/31
  Verifying  : libsemanage-python-2.5-14.el7.x86_64                                                                                    10/31
  Verifying  : selinux-policy-3.13.1-229.el7_6.9.noarch                                                                                11/31
  Verifying  : libsemanage-2.5-14.el7.x86_64                                                                                           12/31
  Verifying  : selinux-policy-targeted-3.13.1-229.el7_6.9.noarch                                                                       13/31
  Verifying  : libsepol-2.5-10.el7.x86_64                                                                                              14/31
  Verifying  : libselinux-python-2.5-14.1.el7.x86_64                                                                                   15/31
  Verifying  : audit-libs-python-2.8.4-4.el7.x86_64                                                                                    16/31
  Verifying  : libselinux-utils-2.5-14.1.el7.x86_64                                                                                    17/31
  Verifying  : 1:docker-ce-cli-18.09.3-3.el7.x86_64                                                                                    18/31
  Verifying  : libselinux-2.5-14.1.el7.x86_64                                                                                          19/31
  Verifying  : 3:docker-ce-18.09.3-3.el7.x86_64                                                                                        20/31
  Verifying  : containerd.io-1.2.4-3.1.el7.x86_64                                                                                      21/31
  Verifying  : libsemanage-2.5-11.el7.x86_64                                                                                           22/31
  Verifying  : libselinux-python-2.5-12.el7.x86_64                                                                                     23/31
  Verifying  : audit-libs-2.8.1-3.el7.x86_64                                                                                           24/31
  Verifying  : policycoreutils-2.5-22.el7.x86_64                                                                                       25/31
  Verifying  : audit-2.8.1-3.el7.x86_64                                                                                                26/31
  Verifying  : libsepol-2.5-8.1.el7.x86_64                                                                                             27/31
  Verifying  : selinux-policy-3.13.1-192.el7.noarch                                                                                    28/31
  Verifying  : libselinux-2.5-12.el7.x86_64                                                                                            29/31
  Verifying  : libselinux-utils-2.5-12.el7.x86_64                                                                                      30/31
  Verifying  : selinux-policy-targeted-3.13.1-192.el7.noarch                                                                           31/31

Installed:
  docker-ce.x86_64 3:18.09.3-3.el7

Dependency Installed:
  audit-libs-python.x86_64 0:2.8.4-4.el7      checkpolicy.x86_64 0:2.5-8.el7                      container-selinux.noarch 2:2.74-1.el7
  containerd.io.x86_64 0:1.2.4-3.1.el7        docker-ce-cli.x86_64 1:18.09.3-3.el7                libcgroup.x86_64 0:0.41-20.el7
  libsemanage-python.x86_64 0:2.5-14.el7      policycoreutils-python.x86_64 0:2.5-29.el7_6.1      python-IPy.noarch 0:0.75-6.el7
  setools-libs.x86_64 0:3.3.8-4.el7

Dependency Updated:
  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.9
  selinux-policy-targeted.noarch 0:3.13.1-229.el7_6.9

Complete!

这样就安装好了。
可能有朋友会问,太麻烦有没有简单一点的安装步骤,一步到位的那种,不好意思,还真没有,这里有两步到位的!可以试试。说不定能成功。


4.脚本一键安装

在测试或开发环境中 Docker 官方为了简化安装流程,提供了一套便捷的安装脚本,CentOS 系统上可以使用这套脚本安装:

$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun

执行这个命令后,脚本就会自动的将一切准备工作做好,并且把 Docker CE 的 Edge 版本安装在系统中。
--PS:我自己反正没成功,你们可以试试看。


5.启动 Docker CE

[root@localhost ~]# sudo systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]# sudo systemctl start docker

到这一步就安装好了!哎。小白不容易,需要努力啊!


6.查看下版本

[root@localhost ~]# docker version
Client:
 Version:           18.09.3
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        774a1f4
 Built:             Thu Feb 28 06:33:21 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.3
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       774a1f4
  Built:            Thu Feb 28 06:02:24 2019
  OS/Arch:          linux/amd64
  Experimental:     false

这个18版本还好不是很老的版本。


7.测试 Docker 是否安装正确

[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
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/

若能正常输出以上信息,则说明安装成功。
谢谢。


相关文章

网友评论

      本文标题:Centos 7.5 安装Docker

      本文链接:https://www.haomeiwen.com/subject/xqrvpqtx.html