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 Copy linkLink copied to clipboard!
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. Therelease-x86_64.json
andrelease-aarch64.json
files from this RPM reside in the/usr/share/microshift/release/
directory. These files contain image references required by MicroShift.
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 Copy linkLink copied to clipboard!
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.
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
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
$ podman build --secret id=pullsecret,src=/<path/to/pull/secret>.json
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the path to your pull secret in <path/to/pull/secret>.
Add the instructions to physically embed the image at build time by adding the following to your Containerfile:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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
.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:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Next steps
- Build the image.
- Test and deploy per your use case.