Migration
[!CAUTION] The
bootc-image-builderrepository has been merged into theimage-builderrepository. All issues have been migrated and this repository has been archived.
bootc-image-builder
A container to create disk images from bootc container inputs, especially oriented towards Fedora/CentOS bootc or derivatives.
๐จ Installationโ
Have podman installed on your system. Either through your systems package manager if you're on Linux or through Podman Desktop if you are on macOS or Windows. If you want to run the resulting virtual machine(s) or installer media you can use qemu.
A very nice GUI extension for Podman Desktop is also available. The command line examples below can be all handled by Podman Desktop.
On macOS, the podman machine must be running in rootful mode:
$ podman machine stop # if already running
Waiting for VM to exit...
Machine "podman-machine-default" stopped successfully
$ podman machine set --rootful
$ podman machine start
โ Prerequisitesโ
If you are on a system with SELinux enforced: The package osbuild-selinux or equivalent osbuild SELinux policies must be installed in the system running
bootc-image-builder.
๐ Examplesโ
The following example builds a centos-bootc:stream9 bootable container into a QCOW2 image for the architecture you're running
the command on. However, be sure to see the upstream documentation
for more general information! Note that outside of initial experimentation, it's recommended to build a derived container image
(or reuse a derived image built via someone else) and then use this project to make a disk image from your custom image.
The generic base images do not include a default user. This example injects a user configuration file by adding a volume-mount for the local file to the bootc-image-builder container.
The following command will create a QCOW2 disk image. First, create ./config.toml as described above to configure user access.
# Ensure the image is fetched
sudo podman pull quay.io/centos-bootc/centos-bootc:stream9
mkdir output
sudo podman run \
--rm \
-it \
--privileged \
--pull=newer \
--security-opt label=type:unconfined_t \
-v ./config.toml:/config.toml:ro \
-v ./output:/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest \
--type qcow2 \
--use-librepo=True \
quay.io/centos-bootc/centos-bootc:stream9
Note that some images (like fedora) do not have a default root
filesystem type. In this case adds the switch --rootfs <type>,
e.g. --rootfs btrfs.
Rootlessโ
There is experimental support for rootless builds in bootc-image-builder. To perform a rootless build KVM is used. The above example can be tried like so:
# Ensure the image is fetched
podman pull quay.io/fedora/fedora-bootc:latest
mkdir output
podman run \
--rm \
-it \
--privileged \
--pull=newer \
--security-opt label=type:unconfined_t \
-v ./config.toml:/config.toml:ro \
-v ./output:/output \
-v ~/.local/share/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest \
--in-vm \
--type qcow2 \
--use-librepo=True \
--rootfs ext4 \
quay.io/fedora/fedora-bootc:latest
Note the mounting of the users container storage, addition of the --in-vm argument and the removal of sudo in the commands.
Running the resulting QCOW2 file on Linux (x86_64)โ
A virtual machine can be launched using qemu-system-x86_64 or with virt-install as shown below;
however there is more information about virtualization and other
choices in the Fedora/CentOS bootc documentation.
qemu-system-x86_64โ
qemu-system-x86_64 \
-M accel=kvm \
-cpu host \
-smp 2 \
-m 4096 \
-bios /usr/share/OVMF/OVMF_CODE.fd \
-serial stdio \
-snapshot output/qcow2/disk.qcow2
virt-installโ
sudo virt-install \
--name fedora-bootc \
--cpu host \
--vcpus 4 \
--memory 4096 \
--import --disk ./output/qcow2/disk.qcow2,format=qcow2 \
--os-variant fedora-eln
Running the resulting QCOW2 file on macOS (aarch64)โ
This assumes qemu was installed through homebrew.
qemu-system-aarch64 \
-M accel=hvf \
-cpu host \
-smp 2 \
-m 4096 \
-bios /opt/homebrew/Cellar/qemu/8.1.3_2/share/qemu/edk2-aarch64-code.fd \
-serial stdio \
-machine virt \
-snapshot output/qcow2/disk.qcow2
๐ Argumentsโ
Usage:
sudo podman run \
--rm \
-it \
--privileged \
--pull=newer \
--security-opt label=type:unconfined_t \
-v ./output:/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest \
<imgref>
Flags:
--chown string chown the ouput directory to match the specified UID:GID
--output string artifact output directory (default ".")
--progress string type of progress bar to use (e.g. verbose,term) (default "auto")
--rootfs string Root filesystem type. If not given, the default configured in the source container image is used.
--target-arch string build for the given target architecture (experimental)
--type stringArray image types to build [ami, anaconda-iso, bootc-installer, gce, iso, qcow2, raw, vhd, vmdk] (default [qcow2])
--version version for bootc-image-builder
Global Flags:
--log-level string logging level (debug, info, error); default error
-v, --verbose Switch to verbose mode
Detailed description of optional flagsโ
| Argument | Description | Default Value |
|---|---|---|
| --chown | chown the output directory to match the specified UID:GID | โ |
| --output | output the artifact into the given output directory | . |
| --progress | Show progress in the given format, supported: verbose,term,debug. If empty it is auto-detected | auto |
| --rootfs | Root filesystem type. Overrides the default from the source container. Supported values: ext4, xfs, btrfs | โ |
| --type | Image type to build (can be passed multiple times) | qcow2 |
| --target-arch | Target arch to build | โ |
| --log-level | Change log level (debug, info, error) | error |
| -v,--verbose | Switch output/progress to verbose mode (implies --log-level=info) | false |
| --use-librepo | Download rpms using librepo (faster and more robust) | false |
The --type parameter can be given multiple times and multiple
outputs will be produced. Note that comma or space separating the
image-typeswill not work, but this example will: --type qcow2 --type ami.
๐ก Tip: Flags in bold are the most important ones.