构建centos docker基础镜像

1、介绍

比较老的版本docker镜像,不太好找,可以尝试自己构建

各版本构建基础镜像方法不太一样,方式也不同,自己尝试,本文只介绍了我自己的尝试
2、构建centos5.11 docker镜像

准备iso文件

(1)安装操作系统

(2)准备repo镜像

因为官方不在支持选择本地iso的方式构建,使用html,或者ftp最好

(3)生成rootfs

精简版本,安装rootfs 300m

bash 复制代码
yum --installroot=/rootfs install bash coreutils yum centos-release -y

最小安装或者是base版本 900m

bash 复制代码
yum --installroot=/rootfs  groupinstall "Base"

删除yum缓存

rm -rf var/cache/yum/

(4)安装完成后替换自己本地的repo镜像文件

(5)导出rootfs

bash 复制代码
tar --numeric-owner -czf centos5_11-root.tar.gz -C /rootfs/ .

(6)构建docker镜像

dockerfile

bash 复制代码
FROM scratch
ADD ./centos5_11-root.tar.gz /
CMD ["/bin/bash"]

构建

bash 复制代码
docker build -t centos5.11:v1 .

(7)运行容器测试

bash 复制代码
docker run -it centos5.11:v1 /bin/bash

源也是可用的

相关推荐
slongzhang_5 小时前
linux 递归删除源码文件|递归删除目录下 *.js,但排除 *.min.js
linux·开发语言·javascript
叼烟扛炮5 小时前
Linux 学习笔记(三十三):线程互斥——互斥锁(Mutex)与死锁
linux·运维·服务器·笔记·学习·1024程序员节
无足鸟ICT5 小时前
【RHCA+】who命令(查看已登陆用户)
linux·运维·服务器
Escalating_xu5 小时前
【Linux 网络编程】应用层协议 HTTP(下):Header、连接管理与 C++ HTTP 服务器
linux·服务器·网络
GeW8 小时前
新质生产力路线图落地,Linux运维与数据库架构师的机会清单
linux
Brilliantwxx8 小时前
【Linux】 文件访问与路径解析:目录、文件名、dentry、路径缓冲与 dcache 全解析
linux·运维·服务器·开发语言·spring
father_12278 小时前
Greenplum 集群故障恢复与主备同步机制实战
linux·网络·greenplum
csdn_aspnet9 小时前
Docker Prune:完整指南与上手示例
运维·docker·容器·prune
ynchyong9 小时前
linux中的 sed` 与 `seq`
linux·运维·sed·seq·文本工具
七牛云行业应用10 小时前
DeepSeek Harness(dsh)安装完整指南:Windows、macOS、Linux 三平台 + 桌面端与 Web 端全覆盖
linux·windows·macos·ai·ai编程