CentOS 8
Sponsored Link

Buildah : Create an Image from Scratch2019/10/11

 
Create a container image from 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
6d214b3e9b08     *     0f3e07c0138f docker.io/library/centos:latest  centos-working-container
ac4361ea1e36     *     0f3e07c0138f docker.io/library/centos:latest  centos-working-container-1
77bf7d442f41     *                  scratch                          working-container

# mount [scratch] container

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

[root@dlp ~]#
echo $scratchmnt

/var/lib/containers/storage/overlay/3dfe1a3a006ab6eb2ee924ebaa353a260ebf6f9be474b757eb25ec82ca755ee8/merged

# install packages to [scratch] container

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

[root@dlp ~]#
buildah umount $newcontainer

e4e00d3b58a0b9aa9539921b18f9c2d2d42eb06e6a41a419eb42a0aea18267b4

# run container

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

[root@mrsdalloway /]#
[root@mrsdalloway /]#
bin   dev  home  lib64  mnt  proc  run   srv  tmp  var
boot  etc  lib   media  opt  root  sbin  sys  usr

[root@mrsdalloway /]#
# add image

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

Getting image source signatures
Copying blob sha256:1c9fbfe2d75f470fb79e74350063b554f849ad14b5dde2a9bfcefcb5b4037d35
 497.12 MiB / 497.12 MiB  23s
Copying config sha256:a8d4d68cadef31f5411181e30d11d57fcf7452e9888beec21d8f50fe4fff289b
 263 B / 263 B  0s
Writing manifest to image destination
Storing signatures
a8d4d68cadef31f5411181e30d11d57fcf7452e9888beec21d8f50fe4fff289b
[root@dlp ~]#
buildah images

IMAGE NAME                                               IMAGE TAG            IMAGE ID             CREATED AT             SIZE
docker.io/library/centos                                 latest               0f3e07c0138f         Oct 2, 2019 08:19      227 MB
localhost/my-centos                                      latest               0a3ba69587a4         Oct 11, 2019 16:14     263 MB
localhost/centos-minimum                                 latest               a8d4d68cadef         Oct 11, 2019 17:15     1.35 GB
Matched Content