Provisioning Fedora/CentOS bootc on vSphere


You will need the govc tool.

No cloud-init or hypervisor-specific metadata tools included by default

Unlike Fedora Cloud or Fedora CoreOS (or in general many pre-generated disk images) the default base image does not include a tool such as cloud-init or afterburn to fetch SSH keys or execute scripts from the hypervisor.

For more on this, see Cloud Agents.

Generating a container image that includes agents

This example container build injects both open-vm-tools and cloud-init, so that SSH credentials can be injected per virtual machine instantiation.

FROM <base image>
RUN dnf install -y open-vm-tools cloud-init && dnf clean all && rm -rf /var/cache /var/log/dnf && \
    systemctl enable vmtoolsd.service

Include the additional software or tooling you want in your image as well; see Building containers.

Generating a VMDK with bootc-image-builder

This uses bootc-image-builder:

$ podman run --rm -it --privileged -v /var/lib/containers/storage:/var/lib/containers/storage -v .:/output --security-opt label=type:unconfined_t \
  --pull newer {bib-image} --local --type vmdk <your container image>

The generated VMDK file will be present in vmdk/disk.vmdk.

Uploading the VMDK

govc import.vmdk \
    -dc="${DATACENTER}" \
    -ds="${DATASTORE}" \
    -pool="${DATACENTER_POOL}" \
    vmdk/disk.vmdk \

Creating a new virtual machine from the VMDK

govc vm.create \
    -dc="${DATACENTER}" \
    -ds="${DATASTORE}" \
    -pool="{DATACENTER_POOL}" \
    -net="${NETWORK}" \
    -disk.controller=pvscsi \
    -on=false \
    -c=${CPUS} \
    -m=${MEMORY} \
    -g="rhel9_64Guest" \
    -firmware="${FIRMWARE}" \

Attach the VMDK to the VM

govc vm.disk.attach \
    -dc="${DATACENTER}" \
    -ds="${DATASTORE}" \
    -vm="${VM_NAME}" \
    -link=false \