春雷一想 發表於 2019-6-16 22:09:00

Centos 7 安装docker

<h2 id="环境">环境</h2>
<ul>
<li>CentOS Linux release 7.6.1810 (Core)</li>
</ul>
<h2 id="创建安装脚本">创建安装脚本</h2>
<p>新建一个<code>install_docker.sh</code>文件,并写入以下内容:</p>
<pre><code class="language-sh">#!/usr/bin/bash
#

# 卸载老版本
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
# 安装必要的工具包
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# 添加软件源信息
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 安装docker-ce
sudo yum -y install docker-ce docker-ce-cli containerd.io
# 启动docker服务
sudo systemctl start docker
</code></pre>
<p>然后执行该脚本:</p>
<pre><code class="language-sh">sh install_docker.sh
</code></pre>
<p>然后根据提示输入密码就OK了。</p>
<h2 id="屏幕输出信息">屏幕输出信息</h2>
<p>过程如下:</p>
<pre><code class="language-sh">(WeChat) $ sh docker_install.sh
password for master:
Loaded plugins: fastestmirror
No Match for argument: docker
No Match for argument: docker-client
No Match for argument: docker-client-latest
No Match for argument: docker-common
No Match for argument: docker-latest
No Match for argument: docker-latest-logrotate
No Match for argument: docker-logrotate
No Match for argument: docker-engine
No Packages marked for removal
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package device-mapper-persistent-data-0.7.3-3.el7.x86_64 already installed and latest version
Package 7:lvm2-2.02.180-10.el7_6.7.x86_64 already installed and latest version
Resolving Dependencies
--&gt; Running transaction check
---&gt; Package yum-utils.noarch 0:1.1.31-50.el7 will be installed
--&gt; Processing Dependency: python-kitchen for package: yum-utils-1.1.31-50.el7.noarch
--&gt; Processing Dependency: libxml2-python for package: yum-utils-1.1.31-50.el7.noarch
--&gt; Running transaction check
---&gt; Package libxml2-python.x86_64 0:2.9.1-6.el7_2.3 will be installed
---&gt; Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
--&gt; Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch
--&gt; Running transaction check
---&gt; Package python-chardet.noarch 0:2.2.1-1.el7_1 will be installed
--&gt; Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================
Package                                    Arch                               Version                                       Repository                        Size
====================================================================================================================================================================
Installing:
yum-utils                                  noarch                           1.1.31-50.el7                                 base                           121 k
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

Transaction Summary
====================================================================================================================================================================
Install1 Package (+3 Dependent packages)

Total download size: 861 k
Installed size: 4.3 M
Downloading packages:
(1/4): libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm                                                                                             | 247 kB00:00:01   
(2/4): python-chardet-2.2.1-1.el7_1.noarch.rpm                                                                                             | 227 kB00:00:02   
(3/4): python-kitchen-1.1.1-5.el7.noarch.rpm                                                                                                 | 267 kB00:00:00   
(4/4): yum-utils-1.1.31-50.el7.noarch.rpm                                                                                                    | 121 kB00:00:00   
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                               286 kB/s | 861 kB00:00:03   
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-chardet-2.2.1-1.el7_1.noarch                                                                                                            1/4
Installing : python-kitchen-1.1.1-5.el7.noarch                                                                                                                2/4
Installing : libxml2-python-2.9.1-6.el7_2.3.x86_64                                                                                                            3/4
Installing : yum-utils-1.1.31-50.el7.noarch                                                                                                                   4/4
Verifying: libxml2-python-2.9.1-6.el7_2.3.x86_64                                                                                                            1/4
Verifying: python-kitchen-1.1.1-5.el7.noarch                                                                                                                2/4
Verifying: yum-utils-1.1.31-50.el7.noarch                                                                                                                   3/4
Verifying: python-chardet-2.2.1-1.el7_1.noarch                                                                                                            4/4

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               

Complete!
Loaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
docker-ce-stable                                                                                                                           | 3.5 kB00:00:00   
(1/2): docker-ce-stable/x86_64/updateinfo                                                                                                    |   55 B00:00:13   
(2/2): docker-ce-stable/x86_64/primary_db                                                                                                    |28 kB00:00:14   
Resolving Dependencies
--&gt; Running transaction check
---&gt; Package containerd.io.x86_64 0:1.2.5-3.1.el7 will be installed
---&gt; Package docker-ce.x86_64 3:18.09.6-3.el7 will be installed
--&gt; Processing Dependency: container-selinux &gt;= 2.9 for package: 3:docker-ce-18.09.6-3.el7.x86_64
--&gt; Processing Dependency: libseccomp &gt;= 2.3 for package: 3:docker-ce-18.09.6-3.el7.x86_64
--&gt; Processing Dependency: libcgroup for package: 3:docker-ce-18.09.6-3.el7.x86_64
--&gt; Processing Dependency: libseccomp.so.2()(64bit) for package: 3:docker-ce-18.09.6-3.el7.x86_64
---&gt; Package docker-ce-cli.x86_64 1:18.09.6-3.el7 will be installed
--&gt; Running transaction check
---&gt; Package container-selinux.noarch 2:2.95-2.el7_6 will be installed
--&gt; Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.95-2.el7_6.noarch
---&gt; Package libcgroup.x86_64 0:0.41-20.el7 will be installed
---&gt; Package libseccomp.x86_64 0:2.3.1-3.el7 will be installed
--&gt; Running transaction check
---&gt; Package policycoreutils-python.x86_64 0:2.5-29.el7_6.1 will be installed
--&gt; Processing Dependency: setools-libs &gt;= 3.3.8-4 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--&gt; Processing Dependency: libsemanage-python &gt;= 2.5-14 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--&gt; Processing Dependency: audit-libs-python &gt;= 2.1.3-4 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--&gt; Processing Dependency: python-IPy for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--&gt; Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--&gt; Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--&gt; Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--&gt; Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--&gt; Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--&gt; Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--&gt; Running transaction check
---&gt; Package audit-libs-python.x86_64 0:2.8.4-4.el7 will be installed
---&gt; Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---&gt; Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---&gt; Package python-IPy.noarch 0:0.75-6.el7 will be installed
---&gt; Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--&gt; Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================
Package                                       Arch                        Version                                  Repository                               Size
====================================================================================================================================================================
Installing:
containerd.io                                 x86_64                        1.2.5-3.1.el7                            docker-ce-stable                         22 M
docker-ce                                     x86_64                        3:18.09.6-3.el7                        docker-ce-stable                         19 M
docker-ce-cli                                 x86_64                        1:18.09.6-3.el7                        docker-ce-stable                         14 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.95-2.el7_6                           extras                                 39 k
libcgroup                                     x86_64                        0.41-20.el7                              base                                     66 k
libseccomp                                    x86_64                        2.3.1-3.el7                              base                                     56 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

Transaction Summary
====================================================================================================================================================================
Install3 Packages (+9 Dependent packages)

Total download size: 57 M
Installed size: 241 M
Is this ok : y
Downloading packages:
(1/12): container-selinux-2.95-2.el7_6.noarch.rpm                                                                                          |39 kB00:00:01   
(2/12): checkpolicy-2.5-8.el7.x86_64.rpm                                                                                                   | 295 kB00:00:01   
(3/12): audit-libs-python-2.8.4-4.el7.x86_64.rpm                                                                                             |76 kB00:00:02   
containerd.io-1.2.5-3.1.el7.x8 FAILED                                          ======-                                          ] 234 kB/s |13 MB00:03:11 ETA
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.5-3.1.el7.x86_64.rpm: Timeout on https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.5-3.1.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(4/12): libcgroup-0.41-20.el7.x86_64.rpm                                                                                                   |66 kB00:00:00   
(5/12): libsemanage-python-2.5-14.el7.x86_64.rpm                                                                                             | 113 kB00:00:00   
(6/12): python-IPy-0.75-6.el7.noarch.rpm                                                                                                   |32 kB00:00:00   
(7/12): setools-libs-3.3.8-4.el7.x86_64.rpm                                                                                                | 620 kB00:00:01   
(8/12): libseccomp-2.3.1-3.el7.x86_64.rpm                                                                                                    |56 kB00:00:01   
(9/12): policycoreutils-python-2.5-29.el7_6.1.x86_64.rpm                                                                                     | 456 kB00:00:02   
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-18.09.6-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY00:01:13 ETA
Public key for docker-ce-18.09.6-3.el7.x86_64.rpm is not installed
(10/12): docker-ce-18.09.6-3.el7.x86_64.rpm                                                                                                |19 MB00:01:35   
docker-ce-cli-18.09.6-3.el7.x8 FAILED                                          ===========================-                     ]187 B/s |34 MB35:40:50 ETA
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-18.09.6-3.el7.x86_64.rpm: Timeout on https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-18.09.6-3.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(11/12): containerd.io-1.2.5-3.1.el7.x86_64.rpm                                                                                              |22 MB00:01:17   
(12/12): docker-ce-cli-18.09.6-3.el7.x86_64.rpm                                                                                              |14 MB00:00:02   
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                               246 kB/s |57 MB00:03:55   
Retrieving key from https://download.docker.com/linux/centos/gpg
Importing GPG key 0x621E9F35:
Userid   : "Docker Release (CE rpm) &lt;docker@docker.com&gt;"
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From       : https://download.docker.com/linux/centos/gpg
Is this ok : y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libcgroup-0.41-20.el7.x86_64                                                                                                                  1/12
Installing : setools-libs-3.3.8-4.el7.x86_64                                                                                                               2/12
Installing : audit-libs-python-2.8.4-4.el7.x86_64                                                                                                            3/12
Installing : checkpolicy-2.5-8.el7.x86_64                                                                                                                  4/12
Installing : libseccomp-2.3.1-3.el7.x86_64                                                                                                                   5/12
Installing : 1:docker-ce-cli-18.09.6-3.el7.x86_64                                                                                                            6/12
Installing : libsemanage-python-2.5-14.el7.x86_64                                                                                                            7/12
Installing : python-IPy-0.75-6.el7.noarch                                                                                                                  8/12
Installing : policycoreutils-python-2.5-29.el7_6.1.x86_64                                                                                                    9/12
Installing : 2:container-selinux-2.95-2.el7_6.noarch                                                                                                      10/12
Installing : containerd.io-1.2.5-3.1.el7.x86_64                                                                                                             11/12
Installing : 3:docker-ce-18.09.6-3.el7.x86_64                                                                                                               12/12
Verifying: 2:container-selinux-2.95-2.el7_6.noarch                                                                                                         1/12
Verifying: libcgroup-0.41-20.el7.x86_64                                                                                                                  2/12
Verifying: containerd.io-1.2.5-3.1.el7.x86_64                                                                                                            3/12
Verifying: policycoreutils-python-2.5-29.el7_6.1.x86_64                                                                                                    4/12
Verifying: python-IPy-0.75-6.el7.noarch                                                                                                                  5/12
Verifying: libsemanage-python-2.5-14.el7.x86_64                                                                                                            6/12
Verifying: 1:docker-ce-cli-18.09.6-3.el7.x86_64                                                                                                            7/12
Verifying: libseccomp-2.3.1-3.el7.x86_64                                                                                                                   8/12
Verifying: checkpolicy-2.5-8.el7.x86_64                                                                                                                  9/12
Verifying: 3:docker-ce-18.09.6-3.el7.x86_64                                                                                                               10/12
Verifying: audit-libs-python-2.8.4-4.el7.x86_64                                                                                                         11/12
Verifying: setools-libs-3.3.8-4.el7.x86_64                                                                                                                12/12

Installed:
containerd.io.x86_64 0:1.2.5-3.1.el7                   docker-ce.x86_64 3:18.09.6-3.el7                   docker-ce-cli.x86_64 1:18.09.6-3.el7                  

Dependency Installed:
audit-libs-python.x86_64 0:2.8.4-4.el7checkpolicy.x86_64 0:2.5-8.el7          container-selinux.noarch 2:2.95-2.el7_6         libcgroup.x86_64 0:0.41-20.el7
libseccomp.x86_64 0:2.3.1-3.el7         libsemanage-python.x86_64 0:2.5-14.el7policycoreutils-python.x86_64 0:2.5-29.el7_6.1python-IPy.noarch 0:0.75-6.el7
setools-libs.x86_64 0:3.3.8-4.el7      

Complete!
password for master:
</code></pre>


</div>
<div id="MySignature" role="contentinfo">
    <div style="background:#ff6a00; color:#0; font-size:small;">
    <p >
            作者:
            咕咚!
    </p>
    <p >
            出处:
            https://www.cnblogs.com/linga/
    </p>
    <p >
            关于作者:专注虚拟化,运维开发,RPA,Rust,Go,Python!
    </p>

    <p >
             本文版权归作者和博客园共有,禁止*.csdn.net转载,禁止以盈利为目的的转载,转载文章,但未经作者同意必须保留此段声明,且在文章页面明显位置给出,
             原文链接
             如有问题, 可邮件(oldsixa@163.com)咨询.
    </p>


   
</div><br><br>
来源:https://www.cnblogs.com/linga/p/11033233.html
頁: [1]
查看完整版本: Centos 7 安装docker