4.5. 使用 bootc-image-builder 创建 GCE 镜像
为您要运行命令的架构将 RHEL bootc 镜像构建到 gce 镜像。RHEL 基础镜像不包括默认用户。可选,您可以使用 --config 选项注入用户配置来运行 bootc-image-builder 容器。或者,您可以使用 cloud-init 配置基础镜像,以便在第一次引导时注入用户和 SSH 密钥。请参阅 用户和组配置 - 使用 cloud-init 注入用户和 SSH 密钥。
先决条件
- 您已在主机机器上安装了 Podman。
-
您有运行
bootc-image-builder工具的 root 访问权限,并在--privileged模式下运行容器,以构建镜像。
流程
可选:创建一个
config.toml来配置用户访问,例如:[[customizations.user]] name = "user" password = "pass" key = "ssh-rsa AAA ... user@email.com" groups = ["wheel"]运行
bootc-image-builder。另外,如果您想要使用用户访问配置,请将config.toml作为参数传递。注意如果您没有容器存储挂载和
本地镜像选项,则您的镜像必须是公共镜像。以下是创建
gce镜像的示例:$ 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/rhel9/bootc-image-builder:latest \ --type gce \ --config /config.toml \ quay.io/<namespace>/<image>:<tag>您可以在输出文件夹中找到
gce镜像。