CentOS Stream 10
Sponsored Link

Buildah : Create images from Scratch2025/01/20

 

Create container images from an empty container image.

[1] Start to create with [scratch] image.
# create an empty container with [scratch]

[root@dlp ~]#
newcontainer=$(buildah from scratch)

[root@dlp ~]#
buildah containers

CONTAINER ID  BUILDER  IMAGE ID     IMAGE NAME                       CONTAINER NAME
26b34e5e7a96     *     1ef274445e32 quay.io/centos/centos:stream10   centos-working-container
ade3a026557e     *     1ef274445e32 quay.io/centos/centos:stream10   centos-working-container-1
4f99476f816b     *                  scratch                          working-container

# mount [scratch] container

[root@dlp ~]#
scratchmnt=$(buildah mount $newcontainer)

[root@dlp ~]#
echo $scratchmnt

/var/lib/containers/storage/overlay/5a9bb5a2ecfe1a882195c22a5dea4e560239ab69920cdecfdd84168f0c3eb89d/merged

# install packages to [scratch] container

[root@dlp ~]#
dnf -y group install "Minimal Install" --releasever=10-stream --installroot=$scratchmnt
# unmount

[root@dlp ~]#
buildah umount $newcontainer

4f99476f816b2a3bb42b9fa09afd67e7957a1887f14747555c8cb0922ab071fb

# run container

[root@dlp ~]#
buildah run $newcontainer bash

[root@4f99476f816b /]#
[root@4f99476f816b /]#
cat /etc/os-release

NAME="CentOS Stream"
VERSION="10 (Coughlan)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="10"
PLATFORM_ID="platform:el10"
PRETTY_NAME="CentOS Stream 10 (Coughlan)"
ANSI_COLOR="0;31"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:centos:centos:10"
HOME_URL="https://centos.org/"
VENDOR_NAME="CentOS"
VENDOR_URL="https://centos.org/"
BUG_REPORT_URL="https://issues.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 10"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"

[root@4f99476f816b /]#
# add images

[root@dlp ~]#
buildah commit $newcontainer centos-minimum:stream10

Getting image source signatures
Copying blob 2e0145be5aad done   |
Copying config b4cc28a3b7 done   |
Writing manifest to image destination
b4cc28a3b7656355be15d79bfa30cd5fbece7a7077309f73a455b7050c0571aa

[root@dlp ~]#
buildah images

REPOSITORY                 TAG        IMAGE ID       CREATED          SIZE
localhost/centos-minimum   stream10   b4cc28a3b765   24 seconds ago   1.07 GB
localhost/my-centos        latest     5a02d770e9ea   18 minutes ago   329 MB
quay.io/centos/centos      stream10   1ef274445e32   6 days ago       311 MB
Matched Content