17.5. Running Buildah in a container
The procedure demonstrates how to run Buildah in a container and create a working container based on an image.
Prerequisites
-
The
container-toolsmeta-package is installed.
Procedure
Log in to the registry.redhat.io registry:
$ podman login registry.redhat.io Username: myuser@mycompany.com Password: <password> Login Succeeded!Pull and run the
registry.redhat.io/rhel10/buildahimage:# podman run --rm --device /dev/fuse -it \ registry.redhat.io/rhel10/buildah /bin/bash-
The
--rmoption removes theregistry.redhat.io/rhel10/buildahimage after the container exits. -
The
--deviceoption adds a host device to the container. -
The
sys_chroot- capability to change to a different root directory. It is not included in the default capabilities of a container.
-
The
Create a new container using a
registry.access.redhat.com/ubi10/image:# buildah from registry.access.redhat.com/ubi10/ ... ubi10/-working-containerRun the
ls /command inside theubi10/-working-containercontainer:# buildah run --isolation=chroot ubi10/-working-container ls / bin boot dev etc home lib lib64 lost+found media mnt opt proc root run sbin srvOptional: List all images in a local storage:
# buildah images REPOSITORY TAG IMAGE ID CREATED SIZE registry.access.redhat.com/ubi10/ latest ecbc6f53bba0 5 weeks ago 211 MBOptional: List the working containers and their base images:
# buildah containers CONTAINER ID BUILDER IMAGE ID IMAGE NAME CONTAINER NAME 0aaba7192762 * ecbc6f53bba0 registry.access.redhat.com/ub... ubi10/-working-containerOptional: Push the
registry.access.redhat.com/ubi10/image to the a local registry located onregistry.example.com:# buildah push ecbc6f53bba0 registry.example.com:5000/ubi10/ubi