1.2 docker 通过yum源下载依赖包并在离线环境中建立yum源安装docker

1、环境
离线包下载环境(可以上网):Centos 7.3
生产环境(不可上网):RHEL 7.4
2、关闭防火墙、selinux 
systemctl stop firewalld
systemctl disable firewalld
sed -i 's/=enforcing/=disabled/g' /etc/selinux/config
setenforce 0
getenforce
3、修改主机名
hostnamectl set-hostname docker01

4、yum 下载docker离线安装包(不安装,含依赖包)

yum  -y install --downloadonly --downloaddir=/tmp/rpm/ docker
yum  -y install --downloadonly --downloaddir=/tmp/rpm/ yum-utils 
yum  -y install --downloadonly --downloaddir=/tmp/rpm/ device-mapper-persistent-data
yum  -y install --downloadonly --downloaddir=/tmp/rpm/ lvm2
yum  -y install --downloadonly --downloaddir=/tmp/rpm/ vim

yum  -y install --downloadonly --downloaddir=/tmp/rpm/ createrepo


5、将Centos 7.3下载软件包/tmp/rpm/拷贝到RHEL 7.4/tmp/rpm/下

 

6、配置离线yum源(下面开始在RHEL 7.4操作)
rm -f /etc/yum.repos.d/*.repo
echo "[docker]"                                                 >  /etc/yum.repos.d/docker.repo
echo "name=docker"                                                   >> /etc/yum.repos.d/docker.repo
echo "baseurl=file:///tmp/rpm"                          >> /etc/yum.repos.d/docker.repo
echo "enabled=1"                                             >> /etc/yum.repos.d/docker.repo
echo "gpgcheck=0"                                            >> /etc/yum.repos.d/docker.repo

6.2关闭rhel.repo

sed -i 's/enabled=1/enabled=0/g' /etc/yum/pluginconf.d/subscription-manager.conf 

6.3 卸载RHEL 原yum软件,安装Centos yum原件

6.3.1yum卸载

 rpm -e yum-rhn-plugin-2.0.1-9.el7.noarch --nodeps
 rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64  --nodeps
 rpm -e yum-3.4.3-154.el7.noarch  --nodeps

6.3.2 yum安装

rpm -ivh python-chardet-2.2.1-3.el7.noarch.rpm 
rpm -ivh python-kitchen-1.1.1-5.el7.noarch.rpm 
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm 
rpm -ivh yum-3.4.3-150.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm 
rpm -ivh yum-utils-1.1.31-52.el7.noarch.rpm 

 


7、安装 createrepo,将该目录制作成软件仓库(相应软件)

rpm -ivh /tmp/rpm/createrepo-0.9.9-28.el7.noarch.rpm /tmp/rpm/deltarpm-3.6-3.el7.x86_64.rpm /tmp/rpm/python-deltarpm-3.6-3.el7.x86_64.rpm 

 createrepo /tmp/rpm


7.2 检查/etc/yum.repo.d/ 下面,只留docker.repo

7.3清理yum缓存、重新缓存

yum repolist

yum clean all
yum makecache

8、软件包离线安装

yum -y install docker

[报错01]

Error: Package: python-rhsm-1.19.9-1.el7.x86_64 (@anaconda/7.4)
           Requires: python-rhsm-certificates = 1.19.9-1.el7
           Removing: python-rhsm-certificates-1.19.9-1.el7.x86_64 (@anaconda/7.4)
               python-rhsm-certificates = 1.19.9-1.el7
           Obsoleted By: subscription-manager-rhsm-certificates-1.24.13-3.el7.centos.x86_64 (docker)
               python-rhsm-certificates = 1.24.13-3.el7.centos
[解决01]
yum -y remove python-rhsm-certificates-1.19.9-1.el7.x86_64

 

yum -y install docker 

安装完成。

你可能感兴趣的:(Docker,linux)