Buildah : Create an Image from Scratch2019/11/19 |
Create a container image from empty Container Image.
This tutorial is based on the environment [SELinux = disabled].
|
|
[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 2d2ca2cfecd7 * f0858ad3febd docker.io/library/fedora:latest 2d2ca2cfecd73a117a17c3b9c6327b3daa885a8c709378d031ece50e5db9f06e 34f4b72375f6 * f0858ad3febd docker.io/library/fedora:latest fedora-working-container dcd186abe47b * f0858ad3febd docker.io/library/fedora:latest fedora-working-container-1 ad0816dab8d1 * scratch working-container # mount [scratch] container [root@dlp ~]# scratchmnt=$(buildah mount $newcontainer) [root@dlp ~]# echo $scratchmnt /var/lib/containers/storage/overlay/b73a004287787fde226b3c1c73ac4fc08825a44ad851d98119d45a19aec774ed/merged # install packages to [scratch] container [root@dlp ~]# dnf -y group install "Minimal Install" --releasever=31 --installroot=$scratchmnt
# unmount [root@dlp ~]# buildah umount $newcontainer 4243cdc53f1570fb4628fa9eca823cfb6926f5b98d884b008820f003ab8f153c # run container [root@dlp ~]# buildah run $newcontainer bash [root@4243cdc53f15 /]# [root@4243cdc53f15 /]# bin dev home lib64 mnt proc run srv tmp var boot etc lib media opt root sbin sys usr
[root@4243cdc53f15 /]#
# add image [root@dlp ~]# buildah commit $newcontainer fedora-minimum:latest Getting image source signatures Copying blob 4e7842f0afef done Copying config 3659931d67 done Writing manifest to image destination Storing signatures 3659931d679ecc9b3e612057d736b37b10665b0531114b7557b9177e0bcae979[root@dlp ~]# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/fedora-minimum latest 3659931d679e 47 seconds ago 1.03 GB localhost/my-fedora latest c0eb1c228705 21 minutes ago 592 MB docker.io/library/fedora latest f0858ad3febd 2 weeks ago 201 MB |
Sponsored Link |
|