Chapter 4. Creating a fully self-contained bootc image


If you need your bootc image to include everything required to run workloads, use physically-bound container images. Edge-computing scenarios involving embedded systems on specialized devices, high security, or high hardware control scenarios are likely candidates.

4.1. About physically bound bootc image building

When a bootc image is fully self-contained, everything you need to run workloads is embedded with the bootc image, including MicroShift and application container images. The underlying mechanism is to pre-pull physically-bound images during image build and then make them available at runtime.

Because embedded images might change with each system update, you cannot pull the images directly to the default container storage. Additional image stores do not work in this case because of current implementation limits. These limits do not allow bootc image updates for those container images.

The manifest, layer tarballs, and signatures are exported as individual files into the directory. The dir transport type preserves the digest of the image, which is crucial for the original digest to reference the image.

Technical details to understand include the following items:

  • Each image goes into the same top-level directory, but a separate subdirectory.
  • Subdirectories are named after the image reference string SHA.
  • An image list file maps image references to their name SHA.
  • You must install the microshift-release-info RPM to get the image references required by MicroShift.
  • You must have image references for your workloads. Apply the same methods to workload image references that you use for MicroShift image references.
  • When you build the container, you must install the microshift-release-info RPM. The release-x86_64.json and release-aarch64.json files from this RPM reside in the /usr/share/microshift/release/ directory. These files contain image references required by MicroShift.
Important

You must keep track of the name of the image. A tag, digest, or a mix of both can reference images. Choosing the best way to reference the images you need can impact the quality and robustness of workloads.

4.2. Embedding container images into a bootc image

First, you must add instructions to an existing Containerfile to copy the images you want and list them in a file to keep track of the copied image names. Then, you must copy images locally from the /usr/lib/containers/storage directory to the local container storage.

Important

You cannot store images in the default or additional container storage directory when you build bootc images. For example, if you update the additional container store setting in /etc/containers/storage.conf to point to the /usr/lib/containers/storage directory, bootc image updates fail.

Prerequisites

  • You have root access to the host.
  • You installed Podman.
  • You installed skopeo.
  • You have workload image references.
  • You have a Containerfile for building MicroShift images.

Procedure

  1. Add the pull secret to the container build procedure to ensure that images can be pulled by running the following command:

    $ podman build --secret id=pullsecret,src=/<path/to/pull/secret>.json 
    1
    Copy to Clipboard Toggle word wrap
    1
    Specify the path to your pull secret in <path/to/pull/secret>.
  2. Add the instructions to physically embed the image at build time by adding the following to your Containerfile:

    ENV IMAGE_STORAGE_DIR=/usr/lib/containers/storage
    ENV IMAGE_LIST_FILE=${IMAGE_STORAGE_DIR}/image-list.txt
    
    RUN dnf install -y microshift-release-info
    RUN --mount=type=secret,id=pullsecret,dst=/run/secrets/pull-secret.json \
        images="$(jq -r ".images[]" /usr/share/microshift/release/release-"$(uname -m)".json)" ; \
        mkdir -p "${IMAGE_STORAGE_DIR}" ; \
        for img in ${images} ; do \
            sha="$(echo "${img}" | sha256sum | awk '{print $1}')" ; \
            skopeo copy --all --preserve-digests \
                --authfile /run/secrets/pull-secret.json \
                "docker://${img}" "dir:$IMAGE_STORAGE_DIR/${sha}" ; \
            echo "${img},${sha}" >> "${IMAGE_LIST_FILE}" ; \
        done
    Copy to Clipboard Toggle word wrap

    When run, the Containerfile extracts the list of MicroShift container image dependencies from the microshift-release-info RPM and pulls them into a custom /usr/lib/containers/storage directory. The resulting image list file is saved at /usr/lib/containers/storage/image-list.txt.

  3. Next, you must copy container images from the custom directory to the main container storage directory so that they are available to MicroShift. Add a script and a systemd service to your Containerfile to copy the embedded images from the /usr/lib/containers/storage directory to the local container storage. Copying happens at runtime before each MicroShift start. Use the following example:

    RUN cat > /usr/bin/microshift-copy-images <<EOF
    #!/bin/bash
    set -eux -o pipefail
    while IFS="," read -r img sha ; do
        skopeo copy --preserve-digests \
            "dir:${IMAGE_STORAGE_DIR}/\${sha}" \
            "containers-storage:\${img}"
    done < "${IMAGE_LIST_FILE}"
    EOF
    
    RUN chmod 755 /usr/bin/microshift-copy-images && \
        mkdir -p /usr/lib/systemd/system/microshift.service.d
    
    RUN cat > /usr/lib/systemd/system/microshift.service.d/microshift-copy-images.conf <<EOF
    [Service]
    ExecStartPre=/usr/bin/microshift-copy-images
    EOF
    Copy to Clipboard Toggle word wrap

Next steps

  1. Build the image.
  2. Test and deploy per your use case.

4.3. Additional resources

Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat