Buildah : Install2021/03/22 |
Install Buildah that supports to create Container images.
It's possible to create OCI (Open Container Initiative) format image without specific Service Daemon.
|
|
[1] | Install Buildah. |
[root@dlp ~]# dnf -y install buildah
|
[2] | This is the basic usage for Buildah. Create a working container from an image. |
# create a working container from [centos] image [root@dlp ~]# buildah from centos:stream8 Resolved "centos" as an alias (/etc/containers/registries.conf.d/shortnames.conf) Getting image source signatures ... ... Writing manifest to image destination Storing signatures centos-working-container # show container list [root@dlp ~]# buildah containers CONTAINER ID BUILDER IMAGE ID IMAGE NAME CONTAINER NAME 5b03b5f7f695 * 2f3766df23b6 registry.centos.org/centos:la... centos-working-container # show container image list [root@dlp ~]# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE registry.centos.org/centos stream8 2f3766df23b6 3 months ago 217 MB # possible to use images on podman [root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE registry.centos.org/centos stream8 2f3766df23b6 3 months ago 217 MB |
[3] | Operate Working Container. |
# set shell variable [root@dlp ~]# container=$(buildah from centos:stream8) [root@dlp ~]# echo $container centos-working-container-1 # possible to run commands [root@dlp ~]# buildah run $container echo "Hello Buildah World" Hello Buildah World [root@dlp ~]# buildah run $container bash [root@12ab26f7bd2c /]# dnf -y install python36 [root@12ab26f7bd2c /]# [root@dlp ~]# buildah run $container whereis python3 python3: /usr/bin/python3.6 /usr/bin/python3.6m /usr/bin/python3 /usr/lib/python3.6 /usr/lib64/python3.6 /usr/include/python3.6m /usr/share/man/man1/python3.1.gz |
[4] | Copy files into Working Container. |
[root@dlp ~]# echo "buildah test" > buildah.txt [root@dlp ~]# buildah copy $container buildah.txt /tmp/buildah.txt 7553c62d21edda64a3067fa9805a5cd8e5781c6058be12eb9792d7e0e9781ed4[root@dlp ~]# buildah run $container cat /tmp/buildah.txt buildah test |
[5] | Mount filesystem of Working Container. |
[root@dlp ~]# buildah mount $container /var/lib/containers/storage/overlay/afa27e95054ce6a97df933e6bdae66306d67cbfe5a07d676751cacb7f254cb4d/merged[root@dlp ~]# ll /var/lib/containers/storage/overlay/afa27e95054ce6a97df933e6bdae66306d67cbfe5a07d676751cacb7f254cb4d/merged total 0 lrwxrwxrwx. 1 root root 7 Nov 4 00:22 bin -> usr/bin drwxr-xr-x. 2 root root 6 Dec 5 02:37 dev drwxr-xr-x. 1 root root 56 Mar 22 11:13 etc drwxr-xr-x. 2 root root 6 Nov 4 00:22 home ..... .....[root@dlp ~]# buildah umount $container 48fe445847dfdf439059f745ee7f408bb29113f9c82ad2c80ca983d22d30e69f |
[6] | Create a container image from Working Container. |
[root@dlp ~]# buildah commit $container my-centos:latest Getting image source signatures ... ... ... Writing manifest to image destination Storing signatures e7ea5d037c9db1049179e1b2874442298c2b119e649b96a33a8ac70bdd46373f[root@dlp ~]# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/my-centos latest e7ea5d037c9d 25 seconds ago 257 MB registry.centos.org/centos stream8 2f3766df23b6 3 months ago 217 MB # possible to use container images on podman [root@dlp ~]# podman run localhost/my-centos hostname bac19a070c6d |
[7] | Push a container image to specified Registry. |
[root@dlp ~]# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/my-centos latest e7ea5d037c9d 55 seconds ago 257 MB registry.centos.org/centos stream8 2f3766df23b6 3 months ago 217 MB # push [localhost/my-centos] image to [node01.srv.world:5000] registry # if target registry is not on SSL/TLS, need [--tls-verify=false] option [root@dlp ~]# buildah push --tls-verify=false localhost/my-centos node01.srv.world:5000/my-centos Getting image source signatures ... ... ... Writing manifest to image destination Storing signatures
[root@dlp ~]#
curl node01.srv.world:5000/v2/_catalog {"repositories":["my-centos"]} # possible to Pull from other nodes [root@node01 ~]# podman pull --tls-verify=false node01.srv.world:5000/my-centos [root@node01 ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE node01.srv.world:5000/my-centos latest e7ea5d037c9d 21 minutes ago 257 MB registry.centos.org/centos stream8 2f3766df23b6 3 months ago 217 MB |
Sponsored Link |
|