构建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

源也是可用的

相关推荐
DFT计算杂谈6 小时前
无 Root 权限在 Tesla K80 零门槛部署 DeepSeek 大模型
linux·服务器·网络·数据库·机器学习
Zhang~Ling7 小时前
从 fopen 到 struct file:从零开始拆解 Linux 文件 I/O
linux·运维·服务器
DeeplyMind7 小时前
Linux 深入 per-VMA lock:Linux 缺页路径如何摆脱 mmap_lock
linux·per-vma lock
爱写代码的森7 小时前
蒙三方库 | harmony-utils之FileUtil文件重命名与属性查询详解
linux·运维·服务器·华为·harmonyos·鸿蒙·huawei
XMAIPC_Robot9 小时前
软硬协同实时控制|RK3588业务调度+FPGA硬件时序,ethercat实现半导体设备微秒级响应(125us)
linux·arm开发·人工智能·fpga开发
重生的黑客9 小时前
Linux 进程优先级、切换与调度:从孤儿进程到 O(1) 调度模型
linux·运维·服务器·进程优先级·nice
风曦Kisaki10 小时前
#企业级docker私有仓库构建:harbor仓库与阿里云镜像仓库
阿里云·docker·容器
骑上单车去旅行10 小时前
MD5校验对比脚本
linux·服务器·windows
平生幻11 小时前
Linux 常用命令
linux
期待着201311 小时前
docker 安装 ,在centos7.9
运维·docker·容器