Este contenido no está disponible en el idioma seleccionado.
Chapter 4. Creating 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.
4.1. Introducing the RHEL image builder command-line interface Copiar enlaceEnlace copiado en el portapapeles!
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, the image-builder command offers many subcommands to examine the state of configured blueprints and composes.
4.2. RHEL image builder blueprint format Copiar enlaceEnlace copiado en el portapapeles!
RHEL image builder supports blueprints in both the .toml and .json formats.
A typical blueprint file include the following elements:
- The blueprint metadata
name = "<blueprint_name>" description = "<long_form_description_text>" version = "<version>"
name = "<blueprint_name>" description = "<long_form_description_text>" version = "<version>"Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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>"
[[groups]] name = "<group_name>"Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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>"
[[packages]] name = "<package_name>" version = "<package_version>"Copy to Clipboard Copied! Toggle word wrap Toggle overflow package-nameis the name of the package, such ashttpd,gdb-doc, orcoreutils.package-versionis a version to use. This field supportsdnfversion specifications:-
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.
NoteThere are no differences between packages and modules in the RHEL image builder tool. Both are treated as RPM package dependencies.
-
For a specific version, use the exact version number, such as
4.3. Creating a blueprint by using the command line Copiar enlaceEnlace copiado en el portapapeles!
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.
Prerequisites
-
You are logged in as the root user or a user who is a member of the
weldrgroup
Procedure
Create a plain text file with the following contents:
name = "<blueprint_name>" description = "<long_form_description>" version = "<0.0.1>" modules = [] groups = []
name = "<blueprint_name>" description = "<long_form_description>" version = "<0.0.1>" modules = [] groups = []Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<blueprint_name>and<long_form_description>with a name and description for your blueprint.Replace
<0.0.1>with a version number according to the Semantic Versioning scheme.For every package that you want to be included in the blueprint, add the following lines to the file:
[[packages]] name = "<package_name>" version = "<package_version>"
[[packages]] name = "<package_name>" version = "<package_version>"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<package_name>with the name of the package, such ashttpd,gdb-doc, orcoreutils.Optionally, replace
<package_version>with the version to use. This field supportsdnfversion specifications:-
For a specific version, use the exact version number such as
9.6.0. -
For the latest available version, use the asterisk
* -
For the latest minor version, use formats such as
9.*.
-
For a specific version, use the exact version number such as
Customize your blueprints to suit your needs. For example, disable Simultaneous Multi Threading (SMT), add the following lines to the blueprint file:
[customizations.kernel] append = "nosmt=force"
[customizations.kernel] append = "nosmt=force"Copy to Clipboard Copied! Toggle word wrap Toggle overflow For additional customizations available, see Supported image customizations.
Note that
[]and[[]]are different data structures expressed in TOML.-
The
[customizations.kernel]header represents a single table that is defined by a collection of keys and their corresponding value pairs, for example:append = "nosmt=force". -
The
[[packages]]header represents an array of tables. The first instance defines the array and its first table element, for example,name = "package-name"andversion = "package-version", and each subsequent instance creates and defines a new table element in that array, in the order that you defined them.
-
The
-
Save the file, for example, as
<blueprint_name>.tomland close the text editor.
4.4. Creating a system image with RHEL image builder on the command line Copiar enlaceEnlace copiado en el portapapeles!
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.
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.
Prerequisites
- You have a blueprint prepared for the image.
Procedure
Optional: List the image formats you can create:
image-builder list
# image-builder listCopy to Clipboard Copied! Toggle word wrap Toggle overflow Start the compose:
image-builder build <image_type> --blueprint <blueprint_name>
# image-builder build <image_type> --blueprint <blueprint_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
<blueprint_name>with the name of the blueprint, and<image_type>with the type of the image. -
If you do not specify a distro,
image-builderuses the same distribution and version as the host system.
-
Replace
Result
The compose process starts and take 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.
4.5. Basic RHEL image builder command-line commands Copiar enlaceEnlace copiado en el portapapeles!
The RHEL image builder command-line interface offers these basic commands for the image-builder.
- List all available images
image-builder list
# image-builder listCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Filter images by name
image-builder list-images --filter "rhel"
# image-builder list-images --filter "rhel"Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Filter by distribution and architecture
image-builder list-images --filter "distro:rhel-10 arch:s390x"
# image-builder list-images --filter "distro:rhel-10 arch:s390x"Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Change output format
image-builder list-images --filter "distro:rhel-10" --format=json | jq
# image-builder list-images --filter "distro:rhel-10" --format=json | jqCopy to Clipboard Copied! Toggle word wrap Toggle overflow image-builder list-images --filter "distro:rhel-10" --format=shell
# image-builder list-images --filter "distro:rhel-10" --format=shellCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Building images
image-builder build <image-type>
# image-builder build <image-type>Copy to Clipboard Copied! Toggle word wrap Toggle overflow <image-type> is the image type supported for RHEL image builder, such as
qcow2,wsl, between others.- Specify a distribution
image-builder build <image-type> --distro <distro>
# image-builder build <image-type> --distro <distro>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Show the progress of the image creation and detailed steps
image-builder build <image-type> --distro <distro> --with-buildlog
# image-builder build <image-type> --distro <distro> --with-buildlogCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Cross-architecture build
image-builder build <image-type> --arch=riscv64
# image-builder build <image-type> --arch=riscv64Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add a custom repository to the build
image-builder build <image-type> --add-repo=<file:///path/to/my/repo>
# image-builder build <image-type> --add-repo=<file:///path/to/my/repo>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.6. Enabled services on custom images Copiar enlaceEnlace copiado en el portapapeles!
When you use RHEL image builder to configure a custom image, the default services that the image uses are determined by specifications, such as the RHEL version release on which you use the image-builder utility, and the image type.
For example, the ami image type enables 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 |
|
| No extra service is enabled by default |
|
| sshd, chronyd, waagent, cloud-init, cloud-init-local, cloud-config, cloud-final |
|
| sshd, chronyd, vmtoolsd, cloud-init |
You can customize which services to enable during the system boot. However, the customization does not override services enabled by default for the mentioned image types.