Buildah : Install2024/05/13 |
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 [ubuntu] image root@dlp:~# buildah from ubuntu Resolved "ubuntu" as an alias (/etc/containers/registries.conf.d/shortnames.conf) Trying to pull docker.io/library/ubuntu:latest... Getting image source signatures Copying blob 49b384cc7b4a done | Copying config bf3dc08bfe done | Writing manifest to image destination ubuntu-working-container # show container list root@dlp:~# buildah containers CONTAINER ID BUILDER IMAGE ID IMAGE NAME CONTAINER NAME cc1b24f376c9 * bf3dc08bfed0 docker.io/library/ubuntu:latest ubuntu-working-container # show container image list root@dlp:~# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/library/ubuntu latest bf3dc08bfed0 13 days ago 78.7 MB # possible to use images on podman root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/library/ubuntu latest bf3dc08bfed0 13 days ago 78.7 MB |
[3] | Operate Working Container. |
# set shell variable root@dlp:~# container=$(buildah from ubuntu) root@dlp:~# echo $container ubuntu-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@6d38de367b81:/# apt-get update; apt-get -y install python3 root@6d38de367b81:/# root@dlp:~# buildah run $container whereis python3 python3: /usr/bin/python3 /usr/lib/python3 /etc/python3 /usr/share/python3 |
[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/a8ceeebf7417b08ce82a85d782716ac0abbcd78fa70c38bde53204c9254d1655/mergedroot@dlp:~# ll /var/lib/containers/storage/overlay/a8ceeebf7417b08ce82a85d782716ac0abbcd78fa70c38bde53204c9254d1655/merged dr-xr-xr-x 1 root root 4096 May 13 02:06 ./ drwx------ 5 root root 4096 May 13 02:13 ../ lrwxrwxrwx 1 root root 7 Apr 22 13:08 bin -> usr/bin/ drwxr-xr-x 2 root root 4096 Apr 22 13:08 boot/ drwxr-xr-x 2 root root 4096 Apr 29 14:05 dev/ drwxr-xr-x 1 root root 4096 May 13 02:13 etc/ drwxr-xr-x 3 root root 4096 Apr 29 14:05 home/ ..... .....root@dlp:~# buildah umount $container 6d38de367b81abcec744e7535f61ecb898ef1f697e19eb540d0d6a885165630c |
[6] | Create a container image from Working Container. |
root@dlp:~# buildah commit $container my-ubuntu:latest Getting image source signatures Copying blob 80098e3d304c skipped: already exists Copying blob 3b91cf516744 done | Copying config 8f4619e42c done | Writing manifest to image destination 8f4619e42cf09915fe1392e18aabfc7880d0fb2d0a59673f3bd99e463a5c80f3root@dlp:~# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/my-ubuntu latest 8f4619e42cf0 31 seconds ago 158 MB docker.io/library/ubuntu latest bf3dc08bfed0 13 days ago 78.7 MB # possible to use container images on podman root@dlp:~# podman run localhost/my-ubuntu hostname 232c739b508c |
[7] | Push a container image to specified Registry. |
root@dlp:~# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/my-ubuntu latest 03c58cc53f05 4 minutes ago 147 MB docker.io/library/ubuntu latest 2dc39ba059dc 4 hours ago 80.4 MB # push [localhost/my-ubuntu] 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-ubuntu node01.srv.world:5000/my-ubuntu
root@dlp:~#
curl node01.srv.world:5000/v2/_catalog {"repositories":["my-ubuntu"]} # possible to Pull from other nodes root@node01:~# podman pull --tls-verify=false node01.srv.world:5000/my-ubuntu root@node01:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE node01.srv.world:5000/my-ubuntu latest 03c58cc53f05 7 minutes ago 147 MB docker.io/library/registry 2 3a0f7b0a13ef 3 weeks ago 24.7 MB |
Sponsored Link |