Containers are software solutions that package your software processes and microservices to make them executable in all computing environments. The files in it include; application codes, environmental variables, configuration codes, binary programs, software dependencies, and libraries. The process of bundling up these components is known as containerization and the final product is known as a container image. This image is then deployed on all platforms, on the cloud, on-premises data systems, and on Local systems

Podman

Podman stands for Pod Manager tool which is a container engine used in developing, managing, and running Open Container Initiatives (OCI) container images in a production environment. OCI was designed to implement an open governance structure for operating system-level virtualization software containers around container formats and runtimes. The containers can be run by root or non-root users.

Features

  • Docker-compatibel CLI interface.
  • Support pod where a group of containers that share resources is managed together.
  • Support multiple container image formats including docker and OCI.
  • It does not contain a daemon for improved security and less use of resources when idle.
  • Support resource isolations for containers and pods.
  • Full management of images from, pulling from various sources, creating and pushing to registries.
  • Full management of container networking, using CNI, Netavark, and slirp4netns.

Buildah

Buildah is also a command-line tool that facilitates the building of OCI container images. It specializes in building container images by replicating all the commands found on the Docker file. It provides low-level Coreutils for building images where you can build images with and without docker files and root privileges.

Features

  • Allows you to create a container from start or with an image as a starting point
  • It is daemon less.
  • Images can be built on OCI or Traditional formats.
  • Mount and unmount a working container root from a file system.

This guide will show you how to install Podman and Buildah on RHEL 9 / CentOS 9 / AlmaLinux 9.

Install Podman on RHEL 9 / CentOS 9 / AlmaLinux 9

Update your system packages.

sudo yum update -y

Install Epel repo on your system.

sudo yum install epel-release -y

Then install Podman using the following command

sudo yum install podman -y

You can also install Podman from group of container tools:

Check version to confirm the installation.

$ podman --version
podman version 4.0.2

To check more details of Podman use the following command.

$ podman info
host:
  arch: amd64
  buildahVersion: 1.24.1
  cgroupControllers:
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.0-1.el9.x86_64
    path: /usr/bin/conmon

Using Podman on RHEL 9|CentOS 9|AlmaLinux 9

Let us try to run a normal container with an Ubuntu image using podman.

$ podman run --rm -it ubuntu
Resolved "ubuntu" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull docker.io/library/ubuntu:latest...
Getting image source signatures
Copying blob 405f018f9d1d done  
Copying config 2794180907 done  
Writing manifest to image destination
Storing signatures
root@6bed9917e36a:/# 

Then view the image details using the following command. The container is downloaded and automatically logs you in the container.

# cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

To exit out the container, use the follwoing command.

# exit

To pull an image using podman, use the following command

podman pull alpine

To list images, use the following command

$ podman images
REPOSITORY                TAG         IMAGE ID      CREATED      SIZE
docker.io/library/ubuntu  latest      27941809078c  4 weeks ago  80.3 MB
docker.io/library/alpine  latest      e66264b98777  6 weeks ago  5.82 MB

To remove container images, use the rmi option with the container ID.

$ podman rmi ubuntu:latest
Untagged: docker.io/library/ubuntu:latest
Deleted: 27941809078cc9b2802deb2b0bb6feed6c236cde01e487f200e24653533701ee

Install Buildah on RHEL 9|CentOS 9|AlmaLinux 9

Install Buildah

sudo yum install buildah -y

Check the version to confirm installation.

$ buildah -v
buildah version 1.24.2 (image-spec 1.0.2-dev, runtime-spec 1.0.2-dev)

Use Buildah on RHEL 9|CentOS 9|AlmaLinux 9

To create a working container from an image.

$ buildah from centos
Resolved "centos" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull quay.io/centos/centos:latest...
Getting image source signatures
Copying blob 7a0437f04f83 done  
Copying config 300e315adb done  
Writing manifest to image destination
Storing signatures
centos-working-container

To list running containers, use the follwoing command.

$ buildah containers
CONTAINER ID  BUILDER  IMAGE ID     IMAGE NAME                       CONTAINER NAME
34d0919674af     *     300e315adb2f quay.io/centos/centos:latest     centos-working-container

To list container images, use the following command.

$ buildah images
REPOSITORY              TAG      IMAGE ID       CREATED         SIZE
quay.io/centos/centos   latest   300e315adb2f   18 months ago   217 MB

Assign a value to a shell variable to make Buildah CLI return the name of the new container with simple commands.

container=$(buildah from centos)

To see the name of the new container, run the follwoing command.

$ echo $container
centos-working-container-1

Let us run a simple command with the new container,

$ buildah run $container echo "Hello Buildah World"
Hello Buildah World

Run the container bash shell.

buildah run $container bash

Exit out of the container with the follwoing command

$ exit

To install a package on the new container, lets say Java, use the following command.

buildah run $container -- dnf -y install java

To remove a container image, use the -rmi option.

$ buildah rm $container
31039fced70481c1ddedbe84d8a2f4e4e727d1e8302c3a140abfa969335de5c2

Conclusion

This guide shows how to install Podman and Buildah tools on RHEL 9 / CentOS 9 / AlmaLinux 9. Both tools allow one to build container images without having a daemon installed on your system.

More guides on RHEL 9 based systems:

LEAVE A REPLY

Please enter your comment!
Please enter your name here