4.4. bootc-image-builder を使用した VMDK イメージの作成
bootc イメージから仮想マシンディスク (VMDK) を作成し、それを vSphere などの VMware の仮想化プラットフォーム内か、VirtualBox で使用します。
前提条件
- ホストマシンに Podman がインストールされている。
-
podman login registry.redhat.io
使用して Red Hat Registry に認証した。 -
rhel9/bootc-image-builder
コンテナーイメージをプルした。
手順
次の内容の
Containerfile
を作成します。FROM registry.redhat.io/rhel9/rhel-bootc:9.4 RUN dnf -y install cloud-init open-vm-tools && \ ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants && \ rm -rf /var/{cache,log} /var/lib/{dnf,rhsm} && \ systemctl enable vmtoolsd.service
FROM registry.redhat.io/rhel9/rhel-bootc:9.4 RUN dnf -y install cloud-init open-vm-tools && \ ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants && \ rm -rf /var/{cache,log} /var/lib/{dnf,rhsm} && \ systemctl enable vmtoolsd.service
Copy to Clipboard Copied! bootc イメージをビルドします。
podman build . -t localhost/rhel-bootc-vmdk
# podman build . -t localhost/rhel-bootc-vmdk
Copy to Clipboard Copied! 以前に作成した bootc イメージから VMDK ファイルを作成します。
注記コンテナーストレージマウントおよび --local イメージオプションがない場合は、イメージをパブリックにする必要があります。
以下はパブリック VMDK イメージを作成する例です。
podman run \ --rm \ -it \ --privileged \ -v /var/lib/containers/storage:/var/lib/containers/storage \ -v ./output:/output \ --security-opt label=type:unconfined_t \ --pull newer \ registry.redhat.io/rhel9/bootc-image-builder:9.4
# podman run \ --rm \ -it \ --privileged \ -v /var/lib/containers/storage:/var/lib/containers/storage \ -v ./output:/output \ --security-opt label=type:unconfined_t \ --pull newer \ registry.redhat.io/rhel9/bootc-image-builder:9.4 --local \ --type vmdk \ quay.io/<namespace>/<image>:<tag>
Copy to Clipboard Copied! 以下はプライベート VMDK イメージを作成する例です。
podman run \ --rm \ -it \ --privileged \ --pull=newer \ --security-opt label=type:unconfined_t \ -v $(pwd)/config.toml:/config.toml:ro \ -v $(pwd)/output:/output \ -v /var/lib/containers/storage:/var/lib/containers/storage \ registry.redhat.io/rhel9/bootc-image-builder:latest \ --local
# podman run \ --rm \ -it \ --privileged \ --pull=newer \ --security-opt label=type:unconfined_t \ -v $(pwd)/config.toml:/config.toml:ro \ -v $(pwd)/output:/output \ -v /var/lib/containers/storage:/var/lib/containers/storage \ registry.redhat.io/rhel9/bootc-image-builder:latest \ --local --type vmdk \ quay.io/<namespace>/<image>:<tag>
Copy to Clipboard Copied! --local
オプションを指定して、リモートリポジトリーではなくローカルコンテナーストレージを使用して元となるイメージを取得し、VMDK を生成します。
bootc イメージの VMDK ディスクファイルは、output/vmdk
ディレクトリーに保存されます。