6.6. 使用 bootc-image-builder 构建、配置和启动磁盘镜像
您可以使用 Containerfile 将配置注入到自定义镜像中。
流程
创建一个磁盘镜像。以下示例演示了如何将用户添加到磁盘镜像中。
[[blueprint.customizations.user]] name = "user" password = "pass" key = "ssh-rsa AAA ... user@email.com" groups = ["wheel"]-
Name- 用户名。必需 -
password- 未加密的密码。不是必需的 -
Key- SSH 公钥内容。不是必需的 -
groups- 要将用户添加到其中的组的数组。不是必需的
-
运行
bootc-image-builder,并传递以下参数:$ sudo podman run \ --rm \ -it \ --privileged \ --pull=newer \ --security-opt label=type:unconfined_t \ -v $(pwd)/config.toml:/config.toml \ -v $(pwd)/output:/output \ registry.redhat.io/rhel9/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 rhel9
验证
使用 SSH 访问系统:
# ssh -i /<path_to_private_ssh-key> <user1>@<ip-address>
后续步骤
- 部署容器镜像后,您可以对镜像进行更新,并将更改推送到注册中心。请参阅管理 RHEL 可引导镜像。