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

源也是可用的

相关推荐
七歌杜金房1 小时前
我终于又有了自己的 Linux 电脑
linux·debian·mac
tntxia1 天前
linux curl命令详解_curl详解
linux
扛枪的书生1 天前
Linux 网络管理器用法速查
linux
顺风尿一寸1 天前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
lichenyang4532 天前
Docker 学习笔记(五):Docker Compose,用一个 YAML 启动前端、后端和 MongoDB
docker
lichenyang4532 天前
Docker 学习笔记(四):Dockerfile,把项目打成自己的镜像
docker·容器
lichenyang4532 天前
Docker 学习笔记(三):Docker 网络、bridge、子网和容器互通
docker·容器
lichenyang4532 天前
Docker 学习笔记(二):docker run 的参数到底在控制什么?
docker·容器
XIAOHEZIcode2 天前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
唐青枫2 天前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux