CentOS Stream 9
Sponsored Link

Buildah : Create images from Scratch2022/03/15

 
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
516422a4010b     *     44ffcc4acee8 quay.io/centos/centos:stream9    centos-working-container
cfad55e0d3b5     *     44ffcc4acee8 quay.io/centos/centos:stream9    centos-working-container-1
e28f8c4e8ec3     *                  scratch                          working-container

# mount [scratch] container

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

[root@dlp ~]#
echo $scratchmnt

/var/lib/containers/storage/overlay/570c4cc51d32074f252af49ffab1fb98cf246ff06fbe31c8bf2be63c23a91f9d/merged

# install packages to [scratch] container

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

[root@dlp ~]#
buildah umount $newcontainer

e28f8c4e8ec3a5cc92fa77bb556f1c6bf25f19e8302505209ad6ecc784fad45c

# run container

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

[root@e28f8c4e8ec3 /]#
[root@e28f8c4e8ec3 /]#
cat /etc/os-release

NAME="CentOS Stream"
VERSION="9"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="9"
PLATFORM_ID="platform:el9"
PRETTY_NAME="CentOS Stream 9"
ANSI_COLOR="0;31"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:centos:centos:9"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 9"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"

[root@e28f8c4e8ec3 /]#
# add images

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

Getting image source signatures
...
...
Writing manifest to image destination
Storing signatures
f9b7597ecc880f044e92906904d59d3dd328eac5df884bb7683266440db5d7fb

[root@dlp ~]#
buildah images

REPOSITORY                 TAG       IMAGE ID       CREATED          SIZE
localhost/centos-minimum   stream9   f9b7597ecc88   33 seconds ago   804 MB
localhost/my-centos        latest    776f546c925c   13 minutes ago   190 MB
quay.io/centos/centos      stream9   44ffcc4acee8   4 days ago       152 MB
Matched Content