Fedora 32
Sponsored Link

Buildah : Create an Image from Scratch2020/05/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
93183c00b1dd     *     d81c91deec0d registry.fedoraproject.org/fe... fedora-working-container
8c1329996c59     *                  scratch                          working-container

# mount [scratch] container

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

[root@dlp ~]#
echo $scratchmnt

/var/lib/containers/storage/overlay/bbd5c2af2d50102e502f680ea7226b0f631300590b14ad8e1fc9f80bfeea47db/merged

# install packages to [scratch] container

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

[root@dlp ~]#
buildah umount $newcontainer

8c1329996c59c3b14fd36fc964aacd789ac305b3cca8848982f7b0f4c8136421

# run container

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

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

[root@8c1329996c59 /]#
# add image

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

Getting image source signatures
Copying blob 04a55139976b done
Copying config bebb6583ca done
Writing manifest to image destination
Storing signatures
bebb6583caf6890b245047d08961d57a97a81562654d8f43b6f248345f96762c
[root@dlp ~]#
buildah images

REPOSITORY                          TAG      IMAGE ID       CREATED          SIZE
localhost/fedora-minimum            latest   bebb6583caf6   45 seconds ago   1.11 GB
registry.fedoraproject.org/fedora   latest   d81c91deec0d   11 days ago      208 MB
Matched Content