Fedora IoT Bootc Image Example with Quay

Building and Booting a Fedora IoT Bootc Image

This example walks through building and booting a Fedora IoT bootc image using Quay.io, as well as pushing an update to a booted Fedora IoT system.

This example is based on the Fedora bootc documentation about building scratch images; reference the upstream docs here for the latest version/information.
This example assumes the user has a Quay account with the ability to create custom repositories.

To start, create a Containerfile.custom with the following contents:

FROM quay.io/fedora-testing/fedora-bootc:rawhide-standard as builder
RUN /usr/libexec/bootc-base-imagectl build-rootfs --manifest=fedora-iot /target-rootfs

FROM scratch
COPY --from=builder /target-rootfs/ /
LABEL containers.bootc 1
ENV container=oci
STOPSIGNAL SIGRTMIN+3
CMD ["/sbin/init"]

You’re now ready to build a Fedora IoT bootc image using the custom containerfile you made earlier. Use this command:

podman build --cap-add=all --security-opt=label=type:container_runtime_t \
--device /dev/fuse -t localhost/fedora-iot -f Containerfile.custom .

Then, tag your Fedora IoT bootc image:

podman tag localhost/fedora-iot:latest quay.io/[quay repository name]:fedora-iot

Before pushing to Quay.io, you may need to log in:

podman login quay.io

Push your new Fedora IoT bootc image to Quay.io using the following command. Note that you may need to log in again:

podman push quay.io/[quay repository name]:fedora-iot
The next step uses podman-bootc. If you need to install podman-bootc, please follow the instructions in the podman-bootc repository

Now, boot your Fedora IoT bootc image. Open a new terminal window and run:

podman-bootc run --filesystem=ext4 quay.io/[quay repository name]:fedora-iot

podman-bootc will pull your image and boot it inside a VM in the terminal window, allowing you to test everything Fedora IoT bootc images have to offer.

Pushing an Update to your Fedora IoT bootc system

After completing the tutorial above, you now have a functional Fedora IoT bootc system! But what if you need to make a change? Updating a bootc system is remarkably simple — just follow the steps below.

This tutorial assumes you have just completed the above tutorial, and have access to a booted Fedora IoT bootc system.

First, navigate to your cloned Fedora Bootc Base Images repository and create a containerfile named Containerfile.fix with your desired changes.

Next, rebuild your localhost/fedora-iot image using the new containerfile:

podman build --cap-add=all --security-opt=label=type:container_runtime_t \
--device /dev/fuse -t localhost/fedora-iot -f Containerfile.fix .

Tag your updated Fedora IoT bootc image:

podman tag localhost/fedora-iot:latest quay.io/[quay repository name]:fedora-iot

Before pushing to Quay.io, you may need to log in:

podman login quay.io

Push your updated Fedora IoT bootc image to Quay.io, using the command below:

podman push quay.io/[quay repository name]:fedora-iot

After successfully pushing, switch back to your virtual machine running your Fedora IoT bootc image. Download and queue the updated image for your next reboot:

bootc upgrade

Run the following command to see your updated image staged for the next reboot:

bootc status

Reboot your Fedora IoT bootc system and use your new updated image:

reboot

After rebooting, you may need to ssh back into your Fedora IoT bootc system. To do so, first list all podman-bootc VMs:

podman-bootc list

Then find the ID of your desired machine and run the following:

podman-bootc ssh [ID]

After reconnecting, run check the status again:

bootc status

Your updated image should now show up as Booted, and the previous image as Rollback. You have successfully updated your Fedora IoT bootc system!