Use the UBI micro images

Build ultra-lightweight containers by using the UBI micro image and Buildah. This process involves mounting the image and installing software into it from the host, as the image lacks a package manager.

Before you begin

  • The container-tools meta-package is installed.

Procedure

  1. Pull and build the registry.access.redhat.com/ubi10/ubi-micro image:
    # microcontainer=$(buildah from registry.access.redhat.com/ubi10/ubi-micro)
  2. Mount a working container root filesystem:
    # micromount=$(buildah mount $microcontainer)
  3. Install the httpd service to the micromount directory:
    # dnf install \
        --installroot $micromount \
        --releasever=/ \
        --setopt install_weak_deps=false \
        --setopt=reposdir=/etc/yum.repos.d/ \
        --nodocs -y \
        httpd
    # dnf clean all \
        --installroot $micromount
  4. Unmount the root file system on the working container:
    # buildah umount $microcontainer
  5. Create the ubi-micro-httpd image from a working container:
    # buildah commit $microcontainer ubi-micro-httpd

Results

  1. Display details about the ubi-micro-httpd image:
    # podman images ubi-micro-httpd
    localhost/ubi-micro-httpd latest 7c557e7fbe9f  22 minutes ago  151 MB