Centos 7.2.1511 安装 Docker 遇到的问题与解决方案

前端之家收集整理的这篇文章主要介绍了Centos 7.2.1511 安装 Docker 遇到的问题与解决方案前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一、前言

最近在一个集群上安装 Docker,本来多么简单的事却因为网络原因以及系统版本变得曲折了,也由于找到了不适合的解决方案,饶了一个弯,所以特此记录一下安装过程,防止重复踩坑。

==系统版本:Centos 7.2.1511==

二、下载与上传

由于服务器不能连接外网,所以服务器使用的是公司自带的 yum 仓库,但是仓库内没有 Docker 安装包,所以需要自己下载。

下载地址:https://yum.dockerproject.org/repo/main/centos/7/Packages/

下载文件

下载完成后,上传到服务器等待安装

三、安装

依次输入如下命令:

$ sudo yum -y@H_301_31@ localinstall docker-engine-selinux-1.13@H_301_31@.1@H_301_31@-1.@H_301_31@el7.centos@H_301_31@.noarch@H_301_31@.rpm@H_301_31@
$ sudo yum -y@H_301_31@ localinstall docker-engine-1.13@H_301_31@.1@H_301_31@-1.@H_301_31@el7.centos@H_301_31@.x@H_301_31@86_64.rpm@H_301_31@

这里使用yum -y localinstall命令,而不是rpm -ivh,是因为它会自动从仓库中下载并安装相应的依赖包,那么如果指定的仓库中有系统对应的版本,安装就应该是没问题的,但是我所使用的仓库中没有7.2.1511版本的安装包,在该目录下有一个readme文件(通过浏览器打开),内容如下:

This directory@H_301_31@ (and@H_301_31@ version@H_301_31@ of@H_301_31@ CentOS) is deprecated.  For normal@H_301_31@ users,you should use /7@H_301_31@/ and@H_301_31@ not@H_301_31@ /7.2@H_301_31@.1511@H_301_31@/ in@H_301_31@ your path. Please see this FAQ
concerning the@H_301_31@ CentOS release scheme:

https@H_301_31@://wiki.centos.org/FAQ/General

If you know what you are doing,and@H_301_31@ absolutely want to@H_301_31@ remain at@H_301_31@ the@H_301_31@ 7.2@H_301_31@.1511@H_301_31@
level,go to@H_301_31@ http@H_301_31@://vault.centos.org/ for@H_301_31@ packages. 

Please keep in@H_301_31@ mind that 7.2@H_301_31@.1511@H_301_31@ no longer gets any@H_301_31@ updates,nor
any@H_301_31@ security fix's.@H_301_31@

嗯,大概意思就是让我使用版本7目录下的…

==由于对应版本的安装包不存在时发生的异常见附录1==

四、修改 yum 获取的版本

使用如下命令进入修改界面:

sudo vi /etc/yum.repos@H_301_31@.d@H_301_31@/CentOS-Base.repo@H_301_31@

文件如下:

[base]
name@H_301_31@=CentOS-$releasever - Base

baseurl@H_301_31@=http://s7repo01/centos/7.2.1511/os/$basearch/
gpgcheck@H_301_31@=1
gpgkey@H_301_31@=http://s7repo01/centos/RPM-GPG-KEY-CentOS-7

#released updates@H_301_31@
[updates]
name@H_301_31@=CentOS-$releasever - Updates
baseurl@H_301_31@=http://s7repo01/centos/7.2.1511/updates/$basearch/
gpgcheck@H_301_31@=1
gpgkey@H_301_31@=http://s7repo01/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful@H_301_31@
[extras]
name@H_301_31@=CentOS-$releasever - Extras
baseurl@H_301_31@=http://s7repo01/centos/7.2.1511/extras/$basearch/
gpgcheck@H_301_31@=1
gpgkey@H_301_31@=http://s7repo01/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages@H_301_31@
[centosplus]
name@H_301_31@=CentOS-$releasever - Plus
baseurl@H_301_31@=http://s7repo01/centos/7.2.1511/centosplus/$basearch/
gpgcheck@H_301_31@=1
enabled@H_301_31@=0
gpgkey@H_301_31@=http://s7repo01/centos/RPM-GPG-KEY-CentOS-7

将所有的baseurl属性修改为版本7对应的目录路径,baseurl属性修改后如下:

baseurl=http:@H_301_31@//s7repo01/centos@H_301_31@/7/centosplus@H_301_31@/$basearch/@H_301_31@

注:只修改版本号即可,对应的仓库地址可能与此不同,能访问则不必修改

五、继续安装

继续使用如下命令安装:

$ sudo yum -y@H_301_31@ localinstall docker-engine-selinux-1.13@H_301_31@.1@H_301_31@-1.@H_301_31@el7.centos@H_301_31@.noarch@H_301_31@.rpm@H_301_31@
$ sudo yum -y@H_301_31@ localinstall docker-engine-1.13@H_301_31@.1@H_301_31@-1.@H_301_31@el7.centos@H_301_31@.x@H_301_31@86_64.rpm@H_301_31@

如果出现某个仓库不能连接的情况,可使用如下命令禁用掉,例(查看具体的错误信息可获知仓库名称,这里是dockerrepo):

sudo yum-config@H_301_31@-manager@H_301_31@ --@H_301_31@disable dockerrepo

重新输入命令,安装成功

附录1:安装中的问题

Loaded plugins: fastestmirror
Repository cloudera-manager is listed more than once in@H_301_31@ the configuration
Examining docker-engine-selinux-1.13@H_301_31@.1@H_301_31@-1.@H_301_31@el7.centos.noarch.rpm: docker-engine-selinux-1.13@H_301_31@.1@H_301_31@-1.@H_301_31@el7.centos.noarch
Marking docker-engine-selinux-1.13@H_301_31@.1@H_301_31@-1.@H_301_31@el7.centos.noarch.rpm to@H_301_31@ be installed
Resolving Dependencies
--> Running transaction check
---> Package docker-engine-selinux.noarch 0@H_301_31@:1.13@H_301_31@.1@H_301_31@-1.@H_301_31@el7.centos will be installed
--> Processing Dependency: selinux-policy-base@H_301_31@ >= 3.13@H_301_31@.1@H_301_31@-102@H_301_31@ for@H_301_31@ package: docker-engine-selinux-1.13@H_301_31@.1@H_301_31@-1.@H_301_31@el7.centos.noarch
http://s7repo01/centos/7.2.1511/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found@H_301_31@
Trying other mirror.
To address this issue please refer to@H_301_31@ the below knowledge base@H_301_31@ article 

https://access.redhat.com/articles/1320623@H_301_31@

If above article doesn't help to@H_301_31@ resolve this issue please create a bug on https://bugs.centos.org/@H_301_31@

http://s7repo01/centos/7.2.1511/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found@H_301_31@
Trying other mirror.
http://s7repo01/centos/7.2.1511/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found@H_301_31@
Trying other mirror.
Loading mirror speeds from cached hostfile

... 省略

Error: Package: docker-engine-selinux-1.13@H_301_31@.1@H_301_31@-1.@H_301_31@el7.centos.noarch (/docker-engine-selinux-1.13@H_301_31@.1@H_301_31@-1.@H_301_31@el7.centos.noarch)
           Requires: selinux-policy-base@H_301_31@ >= 3.13@H_301_31@.1@H_301_31@-102@H_301_31@
           Installed: selinux-policy-targeted-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7.noarch (@anaconda)
               selinux-policy-base@H_301_31@ = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7
           Available: selinux-policy-minimum-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7.noarch (base@H_301_31@)
               selinux-policy-base@H_301_31@ = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7
           Available: selinux-policy-minimum-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.3@H_301_31@.noarch (updates)
               selinux-policy-base@H_301_31@ = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.3@H_301_31@
           Available: selinux-policy-minimum-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.7@H_301_31@.noarch (updates)
               selinux-policy-base@H_301_31@ = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.7@H_301_31@
           Available: selinux-policy-minimum-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.9@H_301_31@.noarch (updates)
               selinux-policy-base@H_301_31@ = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.9@H_301_31@
           Available: selinux-policy-mls-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7.noarch (base@H_301_31@)
               selinux-policy-base@H_301_31@ = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7
           Available: selinux-policy-mls-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.3@H_301_31@.noarch (updates)
               selinux-policy-base@H_301_31@ = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.3@H_301_31@
           Available: selinux-policy-mls-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.7@H_301_31@.noarch (updates)
               selinux-policy-base@H_301_31@ = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.7@H_301_31@
           Available: selinux-policy-mls-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.9@H_301_31@.noarch (updates)
               selinux-policy-base@H_301_31@ = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.9@H_301_31@
           Available: selinux-policy-targeted-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.3@H_301_31@.noarch (updates)
               selinux-policy-base@H_301_31@ = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.3@H_301_31@
           Available: selinux-policy-targeted-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.7@H_301_31@.noarch (updates)
               selinux-policy-base@H_301_31@ = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.7@H_301_31@
           Available: selinux-policy-targeted-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.9@H_301_31@.noarch (updates)
               selinux-policy-base@H_301_31@ = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.9@H_301_31@
Error: Package: docker-engine-selinux-1.13@H_301_31@.1@H_301_31@-1.@H_301_31@el7.centos.noarch (/docker-engine-selinux-1.13@H_301_31@.1@H_301_31@-1.@H_301_31@el7.centos.noarch)
           Requires: selinux-policy-targeted >= 3.13@H_301_31@.1@H_301_31@-102@H_301_31@
           Installed: selinux-policy-targeted-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7.noarch (@anaconda)
               selinux-policy-targeted = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7
           Available: selinux-policy-targeted-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.3@H_301_31@.noarch (updates)
               selinux-policy-targeted = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.3@H_301_31@
           Available: selinux-policy-targeted-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.7@H_301_31@.noarch (updates)
               selinux-policy-targeted = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.7@H_301_31@
           Available: selinux-policy-targeted-3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.9@H_301_31@.noarch (updates)
               selinux-policy-targeted = 3.13@H_301_31@.1@H_301_31@-60.@H_301_31@el7_2.9@H_301_31@
 You could try@H_301_31@ using --skip-broken to@H_301_31@ work around the problem
 You could try@H_301_31@ running: rpm -Va --nofiles --nodigest

使用rpm命令安装,可看见需要的依赖包

sudo rpm -ivh@H_301_31@ docker-engine@H_301_31@-selinux@H_301_31@-@H_301_31@1.13@H_301_31@.1@H_301_31@-@H_301_31@1.@H_301_31@el7.@H_301_31@centos.@H_301_31@noarch.@H_301_31@rpm 

warning: docker-engine@H_301_31@-selinux@H_301_31@-@H_301_31@1.13@H_301_31@.1@H_301_31@-@H_301_31@1.@H_301_31@el7.@H_301_31@centos.@H_301_31@noarch.@H_301_31@rpm: Header@H_301_31@ V4 RSA/SHA512 Signature,key ID 2@H_301_31@c52609d: NOKEY
error: Failed dependencies:
        policycoreutils-python@H_301_31@ is needed by@H_301_31@ docker-engine@H_301_31@-selinux@H_301_31@-@H_301_31@1.13@H_301_31@.1@H_301_31@-@H_301_31@1.@H_301_31@el7.@H_301_31@centos.@H_301_31@noarch
        selinux-policy@H_301_31@-base@H_301_31@ >=@H_301_31@ 3.13@H_301_31@.1@H_301_31@-@H_301_31@102@H_301_31@ is needed by@H_301_31@ docker-engine@H_301_31@-selinux@H_301_31@-@H_301_31@1.13@H_301_31@.1@H_301_31@-@H_301_31@1.@H_301_31@el7.@H_301_31@centos.@H_301_31@noarch
        selinux-policy@H_301_31@-targeted@H_301_31@ >=@H_301_31@ 3.13@H_301_31@.1@H_301_31@-@H_301_31@102@H_301_31@ is needed by@H_301_31@ docker-engine@H_301_31@-selinux@H_301_31@-@H_301_31@1.13@H_301_31@.1@H_301_31@-@H_301_31@1.@H_301_31@el7.@H_301_31@centos.@H_301_31@noarch

附录2:参考链接

http://www.cnblogs.com/mchina/archive/2013/01/04/2842275.html \
http://www.178linux.com/11404 \
http://www.jianshu.com/p/1fc580b71ea4 \
http://www.jb51.cc/article/p-rmhuylkq-brh.html

猜你在找的CentOS相关文章