CentOS 7
Sponsored Link

Buildah : Create from Scratch2018/08/30

 
Create a container image from empty container image.
[1] Start to create with [scratch] image.
[root@dlp ~]#
newcontainer=$(buildah from scratch)

[root@dlp ~]#
buildah containers

CONTAINER ID  BUILDER  IMAGE ID     IMAGE NAME                       CONTAINER NAME
73939f4effb5     *     5182e96772bf docker.io/library/centos:latest  centos-working-container
5e9fe96b5c0f     *                  scratch                          working-container

# mount [scratch] container

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

[root@dlp ~]#
echo $scratchmnt

/var/lib/containers/storage/overlay/274b88752542b38dce02c332f31032c6cef86cf67f7738d5fb8a8e47cf5a868f/merged

# install packages in [scratch] container

[root@dlp ~]#
yum -y install bash coreutils --releasever=7 --installroot=$scratchmnt
# unmount

[root@dlp ~]#
buildah umount $newcontainer

5e9fe96b5c0f1fc13e0d5bcd45e81df17285cce90a21688bef0691e9a755d152

# run container

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

bash-4.2#
bash-4.2#
bin   dev  home  lib64  mnt  proc  run   srv  tmp  var
boot  etc  lib   media  opt  root  sbin  sys  usr

bash-4.2#
# commit the image

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

Getting image source signatures
Copying blob sha256:3a143b7ad55d76d0113ac74c10e3c76a73f8394f1cd92a6f868ff1483080da0e
 83.06 MiB / 83.06 MiB  4s
Copying config sha256:8b03f6f93c4c95614984f54e58529ea9341d02736eb42b69f4c4bd94b76f3ed1
 279 B / 279 B  0s
Writing manifest to image destination
Storing signatures
8b03f6f93c4c95614984f54e58529ea9341d02736eb42b69f4c4bd94b76f3ed1
[root@dlp ~]#
buildah images

IMAGE ID          IMAGE NAME                             CREATED AT             SIZE
5182e96772bf      docker.io/library/centos:latest        Aug 7, 2018 04:21      208 MB
8b03f6f93c4c      localhost/centos-minimum:latest        Aug 30, 2018 11:02     257 MB
Matched Content