Create system images by using the RHEL image builder CLI
RHEL image builder is a tool for creating custom system images. To control RHEL image builder and create your custom system images, you can use the command line (CLI) or the web console interface.
The RHEL image builder command-line interface Copy linkLink copied!
You can use the RHEL image builder command-line interface (CLI) to create blueprints, by running the image-builder command with the suitable options and subcommands.
By default, you must run the image-builder command as a root user.
The workflow for the command line can be summarized as follows:
- Create a blueprint or export an existing blueprint definition to a plain text file.
- Optional: Edit this file in a text editor.
- Import the blueprint text file back into image builder.
- Run a compose to build an image from the blueprint.
- Export the image file to download it.
Apart from the basic subcommands to create a blueprint, you can use the image-builder command with many subcommands to examine the state of configured blueprints and composes.
RHEL image builder blueprint format Copy linkLink copied!
With RHEL image builder, you can use blueprints in both the .toml and .json formats.
A typical blueprint file includes the following elements:
- The blueprint metadata
-
name = "<blueprint_name>" description = "<long_form_description_text>" version = "<version>"The
<blueprint_name>and<long_form_description_text>fields are the name and description for your blueprint.The
<version>is a version number according to the Semantic Versioning scheme, and is present only once for the entire blueprint file. - Groups to include in the image
-
[[groups]] name = "<group_name>"The
<group_name>entry describes a group of packages to be installed into the image. Groups use the following package categories:- Mandatory
- Default
- Optional
The
group-nameis the name of the group, for example, anaconda-tools, widget, wheel, or users. Blueprints install the mandatory and default packages. There is no mechanism for selecting optional packages.
- Packages to include in the image
-
[[packages]] name = "<package_name>" version = "<package_version>"package-nameis the name of the package, such ashttpd,gdb-doc, orcoreutils.package-versionis a version to use. In this field, you can specify dnfversion constraints as follows:- For a specific version, use the exact version number, such as
8.7.0. - For the latest available version, use the asterisk
*. - For the latest minor version, use a format such as
8.*.Repeat this block for every package to include.
Note There are no differences between packages and modules in the RHEL image builder tool. RHEL image builder treats both as RPM Package Manager (RPM) package dependencies.
- For a specific version, use the exact version number, such as
Create a blueprint by using the command line Copy linkLink copied!
You can create a new blueprint by using the command line (CLI). The blueprint describes the final image and its customizations, such as packages and kernel customizations.
Before you begin Copy linkLink copied!
- You are logged in as the root user or a user who is a member of the
weldrgroup
Procedure Copy linkLink copied!
Create a system image with RHEL image builder on the command line Copy linkLink copied!
To build a customized RHEL image by using the RHEL image builder command-line interface, you must specify a blueprint and an image type. Optionally, you can also specify a distribution.
Before you begin Copy linkLink copied!
- You have a blueprint prepared for the image.
About this task Copy linkLink copied!
If you do not specify a distribution, it uses the same distribution and version as the host system. The architecture is also the same as the one on the host.
Procedure Copy linkLink copied!
Results Copy linkLink copied!
The compose process takes some minutes to complete. You can follow the image building steps until the image is ready.
After the image building process finishes, the image is available for your use at the directory where you create it.
Basic RHEL image builder command-line commands Copy linkLink copied!
Use the RHEL image builder command-line interface to run these basic image-builder commands.
- List all available images
-
# image-builder list - Filter images by name
-
# image-builder list-images --filter "rhel" - Filter by distribution and architecture
-
# image-builder list-images --filter "distro:rhel-10" --filter "arch:s390x"Note The
--filterargument does not support multiplekey:valuepairs within a single expression. To combine multiple filters and narrow down your results, pass each filter individually using a separate--filterflag. - Change output format
-
# image-builder list-images --filter "distro:rhel-10" --format=json | jq# image-builder list-images --filter "distro:rhel-10" --format=shell - Building images
-
# image-builder build <image-type><image-type> is the image type supported for RHEL image builder, such as
qcow2,wsl, and so on. - Specify a distribution
-
# image-builder build <image-type> --distro <distro> - Show the progress of the image creation and detailed steps
-
# image-builder build <image-type> --distro <distro> --with-buildlog - Cross-architecture build
-
# image-builder build <image-type> --arch=riscv64 - Add a custom repository to the build
-
# image-builder build <image-type> --extra-repo=<file:///path/to/my/repo>
Enabled services on custom images Copy linkLink copied!
When you configure a custom image by using RHEL image builder to the RHEL version and image type determine the default services that the image uses.
For example, use the ami image type to enable the sshd, chronyd, and cloud-init services by default. If these services are not enabled, the custom image does not boot.
| Image type | Default enabled Services |
|---|---|
|
|
sshd, cloud-init, cloud-init-local, cloud-config, cloud-final |
|
|
sshd, cloud-init, cloud-init-local, cloud-config, cloud-final |
|
|
cloud-init |
|
|
Do not enable extra services by default |
|
|
sshd, chronyd, waagent, cloud-init, cloud-init-local, cloud-config, cloud-final |
|
|
sshd, chronyd, vmtoolsd, cloud-init |