Buildah : Install2021/08/28 |
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:~# apt -y install buildah
|
[2] | This is the basic usage for Buildah. Create a working container from an image. |
# create a working container from [debian] image root@dlp:~# buildah from debian Resolved "debian" as an alias (/etc/containers/registries.conf.d/shortnames.conf) Getting image source signatures Copying blob 4c25b3090c26 done Copying config fe3c5de034 done Writing manifest to image destination Storing signatures debian-working-container # show container list root@dlp:~# buildah containers CONTAINER ID BUILDER IMAGE ID IMAGE NAME CONTAINER NAME dd2673f1bad6 * fe3c5de03486 docker.io/library/debian:latest debian-working-container # show container image list root@dlp:~# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/library/debian latest fe3c5de03486 11 days ago 129 MB # possible to use images on podman root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/library/debian latest fe3c5de03486 11 days ago 129 MB |
[3] | Operate Working Container. |
# set shell variable root@dlp:~# container=$(buildah from debian) root@dlp:~# echo $container debian-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@6ad9282ae0cc:/# apt-get update; apt-get -y install python3 root@6ad9282ae0cc:/# root@dlp:~# buildah run $container whereis python3 python3: /usr/bin/python3.9 /usr/bin/python3 /usr/lib/python3.9 /usr/lib/python3 /etc/python3.9 /etc/python3 /usr/local/lib/python3.9 /usr/share/python3 /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 7553c62d21edda64a3067fa9805a5cd8e5781c6058be12eb9792d7e0e9781ed4root@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/3fac9db0907578477012da7669a38aff0e7fc9c69595c81defa6e38ac7474067/mergedroot@dlp:~# ll /var/lib/containers/storage/overlay/3fac9db0907578477012da7669a38aff0e7fc9c69595c81defa6e38ac7474067/merged total 92 drwxr-xr-x 2 root root 4096 Aug 15 19:00 bin drwxr-xr-x 2 root root 4096 Apr 10 15:15 boot drwxr-xr-x 2 root root 4096 Aug 15 19:00 dev drwxr-xr-x 1 root root 4096 Aug 28 06:46 etc drwxr-xr-x 2 root root 4096 Apr 10 15:15 home drwxr-xr-x 1 root root 4096 Aug 15 19:00 lib ..... .....root@dlp:~# buildah umount $container 6ad9282ae0cccf7567ffe9c56a6572f6402d52acedaae3934a6bc8afdc848ad3 |
[6] | Create a container image from Working Container. |
root@dlp:~# buildah commit $container my-debian:latest Getting image source signatures Copying blob a881cfa23a78 skipped: already exists Copying blob b6d8b39747d5 done Copying config 7aa4a609ff done Writing manifest to image destination Storing signatures 7aa4a609ff69dcca4ff517cc696e3aba921f54307cff89c678ef2646a1052b13root@dlp:~# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/my-debian latest 7aa4a609ff69 16 seconds ago 181 MB docker.io/library/debian latest fe3c5de03486 11 days ago 129 MB # possible to use container images on podman root@dlp:~# podman run localhost/my-debian hostname ea82e055b05f |
[7] | Push a container image to specified Registry. |
root@dlp:~# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/my-debian latest 7aa4a609ff69 16 seconds ago 181 MB docker.io/library/debian latest fe3c5de03486 11 days ago 129 MB # push [localhost/my-debian] 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-debian node01.srv.world:5000/my-debian
root@dlp:~#
curl node01.srv.world:5000/v2/_catalog {"repositories":["my-debian"]} # possible to Pull from other nodes root@node01:~# podman pull --tls-verify=false node01.srv.world:5000/my-debian root@node01:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE node01.srv.world:5000/my-debian latest 7aa4a609ff69 2 minutes ago 181 MB docker.io/library/debian latest fe3c5de03486 11 days ago 129 MB |
Sponsored Link |