Buildah : Install2021/07/30 |
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 [rockylinux] image [root@dlp ~]# buildah from docker.io/rockylinux/rockylinux rockylinux-working-container # show container list [root@dlp ~]# buildah containers CONTAINER ID BUILDER IMAGE ID IMAGE NAME CONTAINER NAME 28ae0a676f16 * 333da17614b6 docker.io/rockylinux/rockylin... rockylinux-working-container # show container image list [root@dlp ~]# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/rockylinux/rockylinux latest 333da17614b6 5 weeks ago 234 MB # possible to use images on podman [root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/rockylinux/rockylinux latest 333da17614b6 5 weeks ago 234 MB |
[3] | Operate Working Container. |
# set shell variable [root@dlp ~]# container=$(buildah from docker.io/rockylinux/rockylinux) [root@dlp ~]# echo $container rockylinux-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@2dc9c34b8aa8 /]# dnf -y install python36 [root@2dc9c34b8aa8 /]# [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/b41bf5383e934a538c540c9e86b1628568c601a62d7a1c5c99637c5b0a6cf59c/merged[root@dlp ~]# ll /var/lib/containers/storage/overlay/b41bf5383e934a538c540c9e86b1628568c601a62d7a1c5c99637c5b0a6cf59c/merged total 0 lrwxrwxrwx. 1 root root 7 Mar 15 04:28 bin -> usr/bin drwxr-xr-x. 2 root root 6 Jun 21 14:03 dev drwxr-xr-x. 1 root root 56 Jul 30 10:34 etc drwxr-xr-x. 2 root root 6 Mar 15 04:28 home ..... .....[root@dlp ~]# buildah umount $container 2dc9c34b8aa8f63741fc575164544181b64d68e8ba81651a37b2b11b54cb96ce |
[6] | Create a container image from Working Container. |
[root@dlp ~]# buildah commit $container my-rockylinux:latest Getting image source signatures ... ... ... Writing manifest to image destination Storing signatures 5820cb7173a9583e4f676009d182a5b807f89322e4c31d3c743aeb501601eac6[root@dlp ~]# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/my-rockylinux latest 5820cb7173a9 19 seconds ago 282 MB docker.io/rockylinux/rockylinux latest 333da17614b6 5 weeks ago 234 MB # possible to use container images on podman [root@dlp ~]# podman run localhost/my-rockylinux hostname 35862422dc0a |
[7] | Push a container image to specified Registry. |
[root@dlp ~]# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/my-rockylinux latest 5820cb7173a9 47 seconds ago 282 MB docker.io/rockylinux/rockylinux latest 333da17614b6 5 weeks ago 234 MB # push [localhost/my-rockylinux] 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-rockylinux node01.srv.world:5000/my-rockylinux Getting image source signatures ... ... ... Writing manifest to image destination Storing signatures
[root@dlp ~]#
curl node01.srv.world:5000/v2/_catalog {"repositories":["my-rockylinux"]} # possible to Pull from other nodes [root@node01 ~]# podman pull --tls-verify=false node01.srv.world:5000/my-rockylinux [root@node01 ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE node01.srv.world:5000/my-rockylinux latest 5820cb7173a9 7 minutes ago 282 MB docker.io/library/registry 2 1fd8e1b0bb7e 3 months ago 26.8 MB |
Sponsored Link |
|