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

源也是可用的

相关推荐
bosins4 小时前
彻底解决 WSL 2.7+ 空闲自动关闭/内存回收导致 Docker 中断的问题
linux·docker·wsl·dashboard
LongRunning4 小时前
【Linux】H3网络(二)
linux
xx~t5 小时前
嵌入式学习——ARM1
linux·arm开发·嵌入式硬件·arm
xx~t5 小时前
嵌入式——ARM1(详细篇)
linux·arm开发·嵌入式硬件·arm
orangapple6 小时前
在docker里启动 orthancteam/orthanc
docker
fengkai45457 小时前
八、Docker详解4-5
运维·docker
DYWorker0018 小时前
Linux驱动子系统:DMA-Buf —— Consumer和Provider(008)
linux·驱动开发
雯宝9 小时前
Linux 内核函数集
linux
GeW10 小时前
从挂科到高分通过:RHCE快速拿证的10个提分技巧
linux
鸠摩智首席音效师10 小时前
Linux /etc/nsswitch.conf 文件有什么作用 ?
linux