跳转至

使用 dnf --installroot 构建最小 rootfs

  1. 创建 rootfs 目录
mkdir -p /home/wujing/Downloads/ctyunos-rootfs
  1. 使用 dnf 安装最小系统(以 ctyunos 22.06 为例)
dnf -c /etc/yum.repos.d/ctyunos.repo \
    --installroot=/home/wujing/Downloads/ctyunos-rootfs \
    --releasever=22.06 \
    --setopt=install_weak_deps=false \
    --setopt=tsflags=nodocs \
    install bash coreutils ctyunos-release yum
  1. 清理缓存
rm -rf /home/wujing/Downloads/ctyunos-rootfs/var/cache/dnf
  1. 打包 rootfs
cd /home/wujing/Downloads/ctyunos-rootfs
tar --numeric-owner --exclude='./dev/*' --exclude='./proc/*' --exclude='./sys/*' -cvf ../ctyunos-22.06.tar .

5. 导入 Docker

cat /home/wujing/Downloads/ctyunos-22.06.tar | docker import - ctyunos-22.06

6. 测试

docker run -it --rm ctyunos-22.06 /bin/bash

💬 评论