Add software in a minimal UBI container

Install software in minimal UBI containers by using the microdnf command. This command provides essential package management features while keeping the container size small.

Before you begin

  • The container-tools meta-package is installed.

Procedure

  1. Pull and run the registry.access.redhat.com/ubi10/ubi-minimal image:
    $ podman run -it --name myubimin registry.access.redhat.com/ubi10/ubi-minimal
  2. Add a package to the myubimin container:
    • To add a package that is in the UBI repository, do not disable any repositories. For example, to add the bzip2 package:
      # microdnf install bzip2 --setopt install_weak_deps=0
    • To add a package that is in a different host repository, explicitly enable the repository you need. For example, to install the python3-devel package from the codeready-builder-for-rhel-10-x86_64-rpms repository:
      # microdnf install --enablerepo=codeready-builder-for-rhel-10-x86_64-rpms python3-devel --setopt install_weak_deps=0

      The --setopt install_weak_deps=false option disables the installation of weak dependencies. Weak dependencies include recommended or suggested packages that are not strictly required but are often installed by default.

Results

  1. List all enabled repositories inside the container:
    # microdnf repolist
  2. Ensure that the required repositories are listed.
  3. List all installed packages:
    # rpm -qa
  4. Ensure that the required packages are listed.
Note

Installing Red Hat packages that are not inside the Red Hat UBI repositories can limit the ability to distribute the container outside of subscribed RHEL systems.