CentOS 7 上创建本地 Docker Yum 仓库以支持离线 Docker 安装

 本地 Docker Yum 仓库的创建

# 准备一台干净的 Centos 7 机器

# 更新软件包

yum update

[root@localhost ~]# yum update
已加载插件:fastestmirror
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                                                                                                                                  | 3.6 kB  00:00:00     
extras                                                                                                                                                                                                                                | 2.9 kB  00:00:00     
updates                                                                                                                                                                                                                               | 2.9 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                                                                                                                                                                                         | 153 kB  00:00:01     
(2/4): extras/7/x86_64/primary_db     
......

# 安装 createrepo 工具以便创建本地 Yum 仓库

yum -y install createrepo

[root@localhost ~]# yum -y install createrepo
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
......

# 删除当前缓存的 rpm 包,可以直接删除 /var/cache/yum/* 目录中的内容

rm -rf /var/cache/yum/*

[root@localhost ~]# rm -rf /var/cache/yum/*

# 修改 yum.conf 开启缓存 rpm 软件包

sed -i 's/keepcache=0/keepcache=1/' /etc/yum.conf

[root@localhost ~]# sed -i 's/keepcache=0/keepcache=1/' /etc/yum.conf
[root@localhost ~]# head  -12 /etc/yum.conf 
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1  # 开启保留已下载的 rpm 包
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release

# 卸载已安装的 Docker

yum remove docker-ce \

docker-client \

docker-client-latest \

docker-common \

docker-latest \

docker-latest-logrotate \

docker-logrotate \

docker-selinux \

docker-engine-selinux \

docker-engine \

docker \

docker-ce-cli

[root@localhost ~]# yum remove docker-ce \
> docker-client \
> docker-client-latest \
> docker-common \
> docker-latest \
> docker-latest-logrotate \
> docker-logrotate \
> docker-selinux \
> docker-engine-selinux \
> docker-engine \
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值