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
-
Pull and build the
registry.access.redhat.com/ubi10/ubi-micro image:
# microcontainer=$(buildah from registry.access.redhat.com/ubi10/ubi-micro)
-
Mount a working container root filesystem:
# micromount=$(buildah mount $microcontainer)
-
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
-
Unmount the root file system on the working container:
# buildah umount $microcontainer
-
Create the
ubi-micro-httpd image from a working container:
# buildah commit $microcontainer ubi-micro-httpd
Results
- Display details about the
ubi-micro-httpd image:
# podman images ubi-micro-httpd
localhost/ubi-micro-httpd latest 7c557e7fbe9f 22 minutes ago 151 MB