6.7. 使用 bootc-image-builder 将配置注入到生成的磁盘镜像中
您可以使用 build config 将配置注入到自定义镜像中,也就是用于生成的镜像的带有自定义的 .toml 或 .json 文件。build config 文件映射到容器目录中的 /config.toml。自定义在自定义对象下指定。
流程
创建
./config.toml。以下示例演示了如何将用户添加到磁盘镜像中。[[customizations.user]] name = "user" password = "pass" key = "ssh-rsa AAA ... user@email.com" groups = ["wheel"]-
name- 必填项。用户的名称。 -
password- 非必填项。未加密的密码. -
key- 非必填项。公共 SSH 密钥内容。 -
groups- 非必填项。将用户添加到的组数组。
-
运行
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>启动虚拟机,例如使用
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>