Layering bootc images
Layering bootc images¶
Follow these procedures to customize an AutoSD bootc image by layering additional packages, files, and configurations using a Containerfile. The layered image can then be converted to a disk image or pushed to a container registry.
Prerequisites¶
- Podman installed. For installation instructions, see the Podman installation guide.
- Automotive Image Builder installed and configured. For installation instructions, see Installing Automotive Image Builder.
- A base bootc image built with
aib build. For build instructions, see the bootc image building procedure. - A builder image created with
aib build-builder(required for disk image conversion). - Familiarity with the layering concepts described in Bootc image layering.
Procedure¶
-
Build a base image. Before layering, you need a base bootc image. If you have not already built one, run
aib buildwith your manifest:console $ aib build \ --target qemu \ manifest.aib.yml \ localhost/my-base-imageThe command stores the container image in local Podman storage. To log in to the final booted image, the manifest must define root credentials in the
authsection:yaml auth: root_password: $6$xoLqEUz0cGGJRx01$H3H/bFm0myJPULNMtbSsOFd/2BnHqHkMD92Sfxd.EKM9hXTWSmELG8cf205l6dktomuTcgKGGtGDgtvHVXSWU.For additional authentication options, see Creating a custom manifest.
-
Write a Containerfile. Create a Containerfile that references the base image and adds your customizations:
```dockerfile FROM localhost/my-base-image
RUN dnf install -y vim-minimal strace && dnf clean all
COPY my-config.conf /etc/my-app/config.conf ```
The
FROMdirective specifies the base bootc image. Each subsequent instruction adds a new layer. Replacemy-config.confand the destination path with the actual configuration file and target location for your application. Common layering operations include the following directives:RUN dnf installto add packagesCOPYorADDto include configuration files or scriptsRUNto execute setup commands (for example, enabling a systemd service)
Note
The
dnfpackage manager must be present in the base image forRUN dnf installto work. Not all manifests includednfby default. If the base image lacksdnf, the build fails withdnf: command not found. To includednf, add it to the manifestcontent.rpmslist:yaml content: rpms: - dnfIf a prebuilt AutoSD bootc base image is available from a container registry, you can replace the local image reference with the registry URL:
dockerfile FROM registry.example.com/autosd/my-base-image:latest -
Build the layered image. Build the layered image from the Containerfile:
console $ sudo podman build -t localhost/my-layered-image -f Containerfile .The
sudoprefix is required becauseaib buildstores the base image in the root container storage. Building the layered image requires network access to resolve any repositories configured in the base image. If the container build cannot reach the repositories, add--network hostto use the host network stack:console $ sudo podman build --network host -t localhost/my-layered-image -f Containerfile . -
Verify the layered image. Confirm that the layered image was created:
console $ sudo podman images | grep my-layered-imageTo inspect the image contents without converting to a disk image, run the following command:
console $ sudo podman run --rm -it localhost/my-layered-image rpm -q vim-minimal -
Convert to a disk image. Convert the layered image to a bootable disk image using
aib to-disk-image. As already noted in the prerequisites, the builder image must already exist.console $ aib to-disk-image \ localhost/my-layered-image \ my-layered-image.qcow2The output format is inferred from the file extension. To set the format explicitly, use
--format <format>as shown in the following example:console $ aib to-disk-image \ --format raw \ localhost/my-layered-image \ my-layered-image.img -
Boot the image. Boot the disk image in Automotive Image Runner:
console $ air --nographics my-layered-image.imgLog in as
rootusing the password defined in the manifestauthsection.
Deploying the layered image¶
After building and verifying the layered image (step 4), you can deploy it through one of the following paths.
Deploy as a disk image¶
Convert the layered image to a bootable disk image with
aib to-disk-image (steps 5-6 above), then boot it in a VM with air
or flash it onto hardware. For hardware flashing instructions, see
Provisioning hardware.
Deploy as an OTA update¶
Push the layered image to a container registry and update running
systems with bootc switch or bootc update. The disk image conversion
step is not needed for this path.
For the full push-and-update workflow, see the registry workflows procedure.
Key considerations¶
When layering bootc images, keep the following important points in mind:
- The layered image inherits the kernel, target configuration, and partition layout from the base image. Layered changes affect only the root filesystem content.
- Packages installed through
dnf installin the Containerfile must be available in the repositories configured in the base image. - The manifest
authsection in the base image defines the login credentials for the final booted image. The Containerfile does not override these settings unless the layered instructions explicitly modify the relevant files. - Each layer added by the Containerfile increases the container image
size. Combine related
RUNinstructions and clean package caches (for example, rundnf clean all) to help minimize image size.
Next steps¶
- To customize the manifest that produces the base image, see Creating a custom manifest.
- For background on the layering model, see Bootc image layering.