Fedora 43

Buildah : Create images from Scratch2025/11/12

 

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
85736a261f93     *     a9005aba99b1 registry.fedoraproject.org/fe... fedora-working-container
168fc77d5d6a     *     a9005aba99b1 registry.fedoraproject.org/fe... fedora-working-container-1
431b4f1ab2c1     *                  scratch                          working-container

# mount [scratch] container

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

[root@dlp ~]#
echo $scratchmnt

/var/lib/containers/storage/overlay/688aa1a98302666023419985327730c57a668e62e1d7eadb92d9ff746c9aaf79/merged

# install packages to [scratch] container

[root@dlp ~]#
dnf -y group install server-product-environment --releasever=43 --installroot=$scratchmnt --use-host-config
# unmount

[root@dlp ~]#
buildah umount $newcontainer

431b4f1ab2c1de9000a484f25bd6f85c96e62004889959cb7c97e5bc54f9d2f3

# run container

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

bash-5.3#
bash-5.3#
cat /etc/os-release

NAME="Fedora Linux"
VERSION="43 (Server Edition)"
RELEASE_TYPE=stable
ID=fedora
VERSION_ID=43
VERSION_CODENAME=""
PRETTY_NAME="Fedora Linux 43 (Server Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:43"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f43/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=43
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=43
SUPPORT_END=2026-12-02
VARIANT="Server Edition"
VARIANT_ID=server

bash-5.3#
# add images

[root@dlp ~]#
buildah commit $newcontainer fedora-server:latest

Getting image source signatures
Copying blob 3333a3d609a7 done   |
Copying config b470119785 done   |
Writing manifest to image destination
b470119785d9a39882f694d2599dce06f24504fbdd518c954230ffa85b42dec8

[root@dlp ~]#
buildah images

REPOSITORY                          TAG      IMAGE ID       CREATED          SIZE
localhost/fedora-server             latest   b470119785d9   33 seconds ago   1.54 GB
localhost/my-fedora                 latest   d9e0d86542aa   9 minutes ago    325 MB
registry.fedoraproject.org/fedora   latest   a9005aba99b1   2 days ago       186 MB
Matched Content