6.7. 使用 bootc-image-builder 将配置注入到生成的磁盘镜像中


您可以使用 build config 将配置注入到自定义镜像中,也就是用于生成的镜像的带有自定义的 .toml.json 文件。build config 文件映射到容器目录中的 /config.toml。自定义在自定义对象下指定。

流程

  1. 创建 ./config.toml。以下示例演示了如何将用户添加到磁盘镜像中。

    [[customizations.user]]
    name = "user"
    password = "pass"
    key = "ssh-rsa AAA ... user@email.com"
    groups = ["wheel"]
    • name - 必填项。用户的名称。
    • password - 非必填项。未加密的密码.
    • key - 非必填项。公共 SSH 密钥内容。
    • groups - 非必填项。将用户添加到的组数组。
  2. 运行 bootc-image-builder ,并传递以下参数,包括 ./config.toml

    $ sudo podman run \
        --rm \
        -it \
        --privileged \
        --pull=newer \
        --security-opt label=type:unconfined_t \
        -v ./config.toml:/config.toml \
        -v ./output:/output \
        registry.redhat.io/rhel10/bootc-image-builder:latest \
        --type qcow2 \
        --config config.toml \
        quay.io/<namespace>/<image>:<tag>
  3. 启动虚拟机,例如使用 virt-install

    $ sudo virt-install \
      --name bootc \
      --memory 4096 \
      --vcpus 2 \
      --disk qcow2/disk.qcow2 \
      --import \
      --os-variant rhel10

验证

  • 使用 SSH 访问系统:

    # ssh -i /<path_to_private_ssh-key> <user1>_@_<ip-address>
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

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

让开源更具包容性

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

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部