5.8. 使用 bootc-image-builder 创建裸磁盘镜像


您可以使用 bootc- image-builder 将 bootc 镜像转换为采用 MBR 或 GPT 分区表的原始镜像。

RHEL 基础镜像不包括默认用户。您可以使用-- config 选项来注入用户配置,以运行 bootc-image-builder 容器。或者,您可以使用 cloud-init 配置基础镜像,以便在第一次引导时注入用户和 SSH 密钥。请参阅 用户和组配置 - 使用 cloud-init 注入用户和 SSH 密钥

先决条件

  • 您已在主机机器上安装了 Podman。
  • 您有运行 bootc-image-builder 工具的 root 访问权限,并在 --privileged 模式下运行容器,以构建镜像。
  • 您已在容器存储中拉取了目标容器镜像。

流程

  1. 可选:创建一个 config.toml 来配置用户访问,例如:

    [[customizations.user]]
    name = "user"
    password = "pass"
    key = "ssh-rsa AAA ... user@email.com"
    groups = ["wheel"]
  2. 在运行容器前,初始化 输出目录。使用 -p 参数来确保如果目录已存在,命令不会失败:

    $ mkdir -p ./output
  3. 运行 bootc-image-builder。如果要使用用户访问配置,请将 config.toml 作为参数传递。镜像必须可从注册中心访问,如 registry.redhat.io/rhel10/bootc-image-builder:latest

    $ sudo podman run \
        --rm \
        --it \
        --privileged \
        --pull=newer \
        --security-opt label=type:unconfined_t \
        -v /var/lib/containers/storage:/var/lib/containers/storage \
        -v ./config.toml:/config.toml \
        -v ./output:/output \
        registry.redhat.io/rhel10/bootc-image-builder:latest \
        --type raw \
        --config /config.toml \
      quay.io/<namespace>/<image>:<tag>

    您可以在输出目录中找到 .raw 镜像。

后续步骤

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部