Ubuntu 26.04

Buildah : Install2026/05/06

 

Install Buildah that supports to create Container images.

It's possible to create OCI (Open Container Initiative) format image without specific Service Daemon.

[1]

If UFW is enabled, enable Forward policy on it, refer to [1] on here.

[2] Install Buildah.
root@dlp:~#
apt -y install buildah
[3] 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 1c24335ddd46 done   |
Copying blob 6f5c5aa4e145 done   |
Copying config 30ba44506a 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
e7a8eafbd218     *     30ba44506a6d 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   30ba44506a6d   2 weeks ago   111 MB

# possible to use images on podman

root@dlp:~#
podman images

REPOSITORY                TAG         IMAGE ID      CREATED      SIZE
docker.io/library/ubuntu  latest      30ba44506a6d  2 weeks ago  111 MB
[4] 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@c73948ae41f0:/#
apt-get update; apt-get -y install python3

root@c73948ae41f0:/#
root@dlp:~#
buildah run $container whereis python3

python3: /usr/bin/python3 /usr/lib/python3 /etc/python3 /usr/share/python3
[5] Copy files into Working Container.
root@dlp:~#
echo "buildah test" > buildah.txt

root@dlp:~#
buildah copy $container buildah.txt /tmp/buildah.txt

28ca540e3c2895a1cea4aeff57f0f554662c11fc58c6f51a1e237521c813764e
root@dlp:~#
buildah run $container cat /tmp/buildah.txt

buildah test
[6] Mount filesystem of Working Container.
root@dlp:~#
buildah mount $container

/var/lib/containers/storage/overlay/64b4f5d3367a4d4d78cbd2895e0ffbad3ac2f9e0b56880eb79e2a2c151c8ea97/merged
root@dlp:~#
ll /var/lib/containers/storage/overlay/64b4f5d3367a4d4d78cbd2895e0ffbad3ac2f9e0b56880eb79e2a2c151c8ea97/merged

total 80
dr-xr-xr-x 1 root root 4096 May  6 01:06 ./
drwx------ 5 root root 4096 May  6 01:08 ../
drwxr-xr-x 2 root root 4096 Apr 21 17:23 .rock/
lrwxrwxrwx 1 root root    7 Apr 20 08:46 bin@ -> usr/bin
drwxr-xr-x 2 root root 4096 Apr 20 08:46 boot/
drwxr-xr-x 1 root root 4096 Apr 21 02:06 dev/
drwxr-xr-x 1 root root 4096 May  6 01:07 etc/
drwxr-xr-x 3 root root 4096 Apr 21 17:23 home/
.....
.....

root@dlp:~#
buildah umount $container

d20b87ba26081528ec282b1a6ab587fe7d27f988babb07599d2f576eba59f355
[7] Create a container image from Working Container.
root@dlp:~#
buildah commit $container my-ubuntu:latest

Getting image source signatures
Copying blob 0c3db79307ab skipped: already exists
Copying blob f421a7e99ead skipped: already exists
Copying blob a8943018aba0 done   |
Copying config 84ceb54861 done   |
Writing manifest to image destination
84ceb548618d757784fcbe53c9be922eb9fb245888baf41e4363f2a838ea56c7

root@dlp:~#
buildah images

REPOSITORY                 TAG      IMAGE ID       CREATED          SIZE
localhost/my-ubuntu        latest   84ceb548618d   16 seconds ago   194 MB
docker.io/library/ubuntu   latest   30ba44506a6d   2 weeks ago      111 MB

# possible to use container images on podman

root@dlp:~#
podman run localhost/my-ubuntu hostname

fe5f8c34261d
[8] Push a container image to specified Registry.
root@dlp:~#
buildah images

REPOSITORY                 TAG      IMAGE ID       CREATED          SIZE
localhost/my-ubuntu        latest   84ceb548618d   48 seconds ago   194 MB
docker.io/library/ubuntu   latest   30ba44506a6d   2 weeks ago      111 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
Matched Content