Docker Centos/RedHat 内网安装

  • 先找一部能连外网的机器 下载安装包和依赖包
    • yum install --downloadonly --downloaddir=/root/packages/docker-ce docker-ce-17.09.0.ce
    • 在你的/root/packages/docker-ce目录下就能找到docker的相关包和依赖包
     container-selinux-2.28-1.git85ce147.el7.noarch.rpm
     device-mapper-1.02.140-8.el7.x86_64.rpm
     device-mapper-event-1.02.140-8.el7.x86_64.rpm
     device-mapper-event-libs-1.02.140-8.el7.x86_64.rpm
     device-mapper-libs-1.02.140-8.el7.x86_64.rpm
     device-mapper-persistent-data-0.7.0-0.1.rc6.el7.x86_64.rpm
     docker-ce-17.09.0.ce-1.el7.centos.x86_64.rpm
     libsemanage-2.5-8.el7.x86_64.rpm
     libsemanage-python-2.5-8.el7.x86_64.rpm
     lvm2-2.02.171-8.el7.x86_64.rpm
     lvm2-libs-2.02.171-8.el7.x86_64.rpm
     policycoreutils-2.5-17.1.el7.x86_64.rpm
     policycoreutils-python-2.5-17.1.el7.x86_64.rpm
     selinux-policy-3.13.1-166.el7_4.5.noarch.rpm
     selinux-policy-targeted-3.13.1-166.el7_4.5.noarch.rpm
     setools-libs-3.3.8-1.1.el7.x86_64.rpm
    
  • 上传到内网服务器,试着直接安装docker,看看看依赖那些库
rpm -ivh docker-ce-17.09.0.ce-1.el7.centos.x86_64.rpm
warning: docker-ce-17.09.0.ce-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
error: Failed dependencies:
    container-selinux >= 2.9 is needed by docker-ce-17.09.0.ce-1.el7.centos.x86_64
    libcgroup is needed by docker-ce-17.09.0.ce-1.el7.centos.x86_64
    libltdl.so.7()(64bit) is needed by docker-ce-17.09.0.ce-1.el7.centos.x86_64
    libseccomp.so.2()(64bit) is needed by docker-ce-17.09.0.ce-1.el7.centos.x86_64
  • 试着安装container-selinux的包
rpm -ivh container-selinux-2.28-1.git85ce147.el7.noarch.rpm
warning: container-selinux-2.28-1.git85ce147.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
    policycoreutils >= 2.5-11 is needed by container-selinux-2:2.28-1.git85ce147.el7.noarch
    policycoreutils-python is needed by container-selinux-2:2.28-1.git85ce147.el7.noarch
  • 试着安装policycoreutils-2.5-17.1.el7.x86_64.rpm包
rpm -ivh policycoreutils-2.5-17.1.el7.x86_64.rpm
warning: policycoreutils-2.5-17.1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
    libselinux-utils >= 2.5-6 is needed by policycoreutils-2.5-17.1.el7.x86_64
    libsemanage.so.1(LIBSEMANAGE_1.1)(64bit) is needed by policycoreutils-2.5-17.1.el7.x86_64
    libsepol >= 2.5-6 is needed by policycoreutils-2.5-17.1.el7.x86_64
    libsepol.so.1(LIBSEPOL_1.0)(64bit) is needed by policycoreutils-2.5-17.1.el7.x86_64
    libsepol.so.1(LIBSEPOL_1.1)(64bit) is needed by policycoreutils-2.5-17.1.el7.x86_64
  • 试到这就不用再试了,系统类库(.so)都出来了,系统缺东西,安装linux系统的时候估计是最小化安装,我们试着挂镜像作为本地yum源吧,系统镜像里有一些基础类库,可以看到container-selinux依赖于policycoreutils >= 2.5-11,即policycoreutils版本大于等于2.5-11,这个版本的policycoreutils只有Centos/RedHat镜像的版本至少大于7.4(具体是那个版本才有2.5没研究过),RedHat7.4下载,挂镜像的详细方法见上面的链接
# 挂载镜像(先创建`/mnt/cdrom/`文件夹)
mount -o loop /opt/iso/rhel-server-7.4-x86_64-dvd.iso /mnt/cdrom/

# 编辑yum源配置
# myself.repo 是自定义的名称,随便取
# vi /etc/yum.repos.d/myself.repo
name=RedHat    # 名称,自定义
baseurl=file:///mnt/cdrom # yum 软件包路径
enabled=1 # 启用这个仓库
gpgckeck=0 # 不启用包检查
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
# 保存退出

# 清除所有缓存
yum clean all 

#列出仓库列表
yum repolist  # 列出仓库列表

# 搜索软件包
yum list 软件包名

# 顺便说下怎么卸载镜像
umount /mnt/cdrom/
  • 再次试着安装container-selinux的包
rpm -ivh container-selinux-2.28-1.git85ce147.el7.noarch.rpm
warning: container-selinux-2.28-1.git85ce147.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
    policycoreutils >= 2.5-11 is needed by container-selinux-2:2.28-1.git85ce147.el7.noarch
    policycoreutils-python is needed by container-selinux-2:2.28-1.git85ce147.el7.noarch

查看yum 源里是否有policycoreutils包:

yum list policycoreutils
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
base                                                                                  | 4.1 kB  00:00:00
(1/2): base/group_gz                                                                  | 137 kB  00:00:00
(2/2): base/primary_db                                                                | 4.0 MB  00:00:00
Determining fastest mirrors
Installed Packages
policycoreutils.x86_64                               2.2.5-20.el7                               @anaconda/7.2
Available Packages
policycoreutils.x86_64                               2.5-17.1.el7                               base

显然,版本是对的,直接安装:yum install policycoreutils,同时安装下policycoreutils-python:yum install policycoreutils-python
安装完这俩个包之后rpm -ivh container-selinux-2.28-1.git85ce147.el7.noarch.rpm ,container-selinux这个包就能装上了

  • 再次试着安装docker包
rpm -ivh docker-ce-17.09.0.ce-1.el7.centos.x86_64.rpm
warning: docker-ce-17.09.0.ce-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
error: Failed dependencies:
    libltdl.so.7()(64bit) is needed by docker-ce-17.09.0.ce-1.el7.centos.x86_64
    libseccomp.so.2()(64bit) is needed by docker-ce-17.09.0.ce-1.el7.centos.x86_64

这次只剩俩个依赖包了,libltdl.so和libseccomp.so,执行yum list *ltdl*,模糊搜索有ltdl的包:

yum list *ltdl*
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-
              : manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
Available Packages
libtool-ltdl.i686                             2.4.2-22.el7_3                     base
libtool-ltdl.x86_64                           2.4.2-22.el7_3                     base
libtool-ltdl-devel.i686                       2.4.2-22.el7_3                     base
libtool-ltdl-devel.x86_64                     2.4.2-22.el7_3                     base

我尝试着yum install libltdl.so.7:

================================================================================
 Package                  Arch         Version                 Repository  Size
================================================================================
Installing:
 libtool-ltdl             i686         2.4.2-22.el7_3          base        49 k
Installing for dependencies:
 glibc                    i686         2.17-196.el7            base       4.2 M
 nss-softokn-freebl       i686         3.28.3-6.el7            base       198 k
Updating for dependencies:
 glibc                    x86_64       2.17-196.el7            base       3.6 M
 glibc-common             x86_64       2.17-196.el7            base        11 M
 glibc-devel              x86_64       2.17-196.el7            base       1.1 M
 glibc-headers            x86_64       2.17-196.el7            base       675 k
 nss-softokn-freebl       x86_64       3.28.3-6.el7            base       213 k

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

然后执行rpm -ivh docker-ce-17.09.0.ce-1.el7.centos.x86_64.rpm:
报错:Failed to initialize NSS library,哇,心态崩了,不,rpm好像崩了,百度之:

1、下载nspr(nspr-4.13.1-1.0.el7_3.x86_64.rpm)包,链接:[http://mirror.centos.org/centos/7/os/x86_64/Packages/nspr-4.13.1-1.0.el7_3.x86_64.rpm](http://mirror.centos.org/centos/7/os/x86_64/Packages/nspr-4.13.1-1.0.el7_3.x86_64.rpm)

2、执行命令:rpm2cpio nspr-4.13.1-1.0.el7_3.x86_64.rpm | cpio -idmv

3、执行命令:LD_PRELOAD=./usr/lib64/libnspr4.so yum update nspr

原因是 安装相关的glibc.i686包,导致yum、rpm损坏,从yum install libltdl.so.7块的显示信息可以知道的确安装了glibc.i686
以上来自Centos7 error: Failed to initialize NSS library
问题解决之后顺便把(libtool-ltdl.i686,glibc.i686,nss-softokn-freebl.i686)这三个包卸载了

  • 老老实实安装包x86_64包:
# 查询和安装libltdl.so(ltdl库)的x86_6相关包
[root@localhost docker-ce]# yum list *ltdl*
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-
              : manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
Available Packages
libtool-ltdl.i686                          2.4.2-22.el7_3                   base
libtool-ltdl.x86_64                        2.4.2-22.el7_3                   base
libtool-ltdl-devel.i686                    2.4.2-22.el7_3                   base
libtool-ltdl-devel.x86_64                  2.4.2-22.el7_3                   base
[root@localhost docker-ce]# yum install libtool-ltdl.x86_64
[root@localhost docker-ce]# yum install libtool-ltdl-devel.x86_64

# 查询和安装libseccomp.so(seccomp库)x86_64包
[root@localhost docker-ce]#  yum list *seccomp*
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-
              : manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
Available Packages
libseccomp.i686                          2.3.1-3.el7                        base
libseccomp.x86_64                        2.3.1-3.el7                        base
[root@localhost docker-ce]# yum install libseccomp.x86_64
  • 安装docker:
[root@localhost docker-ce]# rpm -ivh docker-ce-17.09.0.ce-1.el7.centos.x86_64.rpm
warning: docker-ce-17.09.0.ce-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:docker-ce-17.09.0.ce-1.el7.centos################################# [100%]
  • 过程中遇到的另外一个问题,在另外一台机器上,好像和上一个问题冲突,哈哈,有时间再研究:# rpm包安装过程中依赖问题“libc.so.6 is needed by XXX”解决方法

你可能感兴趣的:(Docker Centos/RedHat 内网安装)