Buildah : Create images from Scratch2024/11/07 |
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 9e5f4bd9c78b * 0e2b2f101698 registry.fedoraproject.org/fe... fedora-working-container 63d16a1f3443 * 0e2b2f101698 registry.fedoraproject.org/fe... fedora-working-container-1 3fc40a14b693 * scratch working-container # mount [scratch] container [root@dlp ~]# scratchmnt=$(buildah mount $newcontainer) [root@dlp ~]# echo $scratchmnt /var/lib/containers/storage/overlay/161f43b81a12d8ef5a552e30b0d4a9f6300093337586c84cf3459670647ebf13/merged # install packages to [scratch] container [root@dlp ~]# dnf -y group install server-product-environment --releasever=41 --installroot=$scratchmnt --use-host-config
# unmount [root@dlp ~]# buildah umount $newcontainer 3fc40a14b693d354be793501a2ecc8d84b9033b9d6f1d273ad47b7ee39e55880 # run container [root@dlp ~]# buildah run $newcontainer bash [root@3fc40a14b693 /]# [root@3fc40a14b693 /]# cat /etc/os-release NAME="Fedora Linux" VERSION="41 (Server Edition)" RELEASE_TYPE=stable ID=fedora VERSION_ID=41 VERSION_CODENAME="" PLATFORM_ID="platform:f41" PRETTY_NAME="Fedora Linux 41 (Server Edition)" ANSI_COLOR="0;38;2;60;110;180" LOGO=fedora-logo-icon CPE_NAME="cpe:/o:fedoraproject:fedora:41" HOME_URL="https://fedoraproject.org/" DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f41/system-administrators-guide/" SUPPORT_URL="https://ask.fedoraproject.org/" BUG_REPORT_URL="https://bugzilla.redhat.com/" REDHAT_BUGZILLA_PRODUCT="Fedora" REDHAT_BUGZILLA_PRODUCT_VERSION=41 REDHAT_SUPPORT_PRODUCT="Fedora" REDHAT_SUPPORT_PRODUCT_VERSION=41 SUPPORT_END=2025-12-15 VARIANT="Server Edition" VARIANT_ID=server
[root@3fc40a14b693 /]#
# add images [root@dlp ~]# buildah commit $newcontainer fedora-server:latest Getting image source signatures Copying blob 7f0406261bd7 done | Copying config 6503253a5e done | Writing manifest to image destination 6503253a5e5875da49cf506acafcde1d8c84d1bbec5f8a3965899358bc4178b5[root@dlp ~]# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/fedora-server latest 6503253a5e58 19 seconds ago 1.39 GB localhost/my-fedora latest 0ee32bb6225b 39 minutes ago 294 MB registry.fedoraproject.org/fedora latest 0e2b2f101698 18 hours ago 163 MB |
Sponsored Link |