Buildah : Create images from Scratch2021/03/22 |
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 5b03b5f7f695 * 2f3766df23b6 registry.centos.org/centos:la... centos-working-container 48fe445847df * 2f3766df23b6 registry.centos.org/centos:la... centos-working-container-1 7dfacaa35c75 * scratch working-container # mount [scratch] container [root@dlp ~]# scratchmnt=$(buildah mount $newcontainer) [root@dlp ~]# echo $scratchmnt /var/lib/containers/storage/overlay/95a18674e9ef46ddce96cfc881518019f7e28d4bcc3f5c9d7fa5878a898895ba/merged # install packages to [scratch] container [root@dlp ~]# dnf -y group install "Minimal Install" --releasever=8-stream --installroot=$scratchmnt
# unmount [root@dlp ~]# buildah umount $newcontainer 7dfacaa35c7523d2b82d6f957aad28a8c917ee4d95ebb1d6a1992843f4377788 # run container [root@dlp ~]# buildah run $newcontainer bash [root@7dfacaa35c75 /]# [root@7dfacaa35c75 /]# cat /etc/os-release NAME="CentOS Stream" VERSION="8" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="8" PLATFORM_ID="platform:el8" PRETTY_NAME="CentOS Stream 8" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:8" HOME_URL="https://centos.org/" BUG_REPORT_URL="https://bugzilla.redhat.com/" REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8" REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"
[root@7dfacaa35c75 /]#
# add images [root@dlp ~]# buildah commit $newcontainer centos-minimum:latest Getting image source signatures ... ... Writing manifest to image destination Storing signatures a47729971b9565ced690c141d654f6347a54b8ce3675bff8773bee971aa98abb[root@dlp ~]# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/centos-minimum latest a47729971b95 About a minute ago 1.42 GB node01.srv.world:5000/my-centos latest e7ea5d037c9d 36 minutes ago 257 MB registry.centos.org/centos stream8 2f3766df23b6 3 months ago 217 MB |