When running in an existing podman/docker container, SELinux + seccomp prevents effective nesting (UID mapping, etc.), but old-school chroots can still be used to somewhat isolate execution.
buildah supports both puling OCI images and using them via chroots, even for arbitrary command execution (not just building), allowing tests to run in chroots in nicely prepared container images (no need to custom-prepare images).
Basically:
buildah pull to fetch the image
buildah from to prepare a new rootfs ("start a container")
buildah run to run commands in that rootfs as chroot ("podman exec")
buildah rm to delete it
There's likely no PID / network / etc. isolation, so this can never be made to support systemd.
$ dnf -y install buildah
$ buildah --storage-driver vfs containers
CONTAINER ID BUILDER IMAGE ID IMAGE NAME CONTAINER NAME
$ buildah --storage-driver vfs pull fedora:44
Resolved "fedora" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull registry.fedoraproject.org/fedora:44...
Getting image source signatures
Copying blob b1ad493156b5 done |
Copying config 338bec00ee done |
Writing manifest to image destination
338bec00ee4404d6ba6624d577c6bd3a47e10469e4658ac9c3d756fc1b0fb683
$ buildah --storage-driver vfs from --isolation chroot --pull=never 338bec00ee44
fedora-working-container
$ buildah --storage-driver vfs run --isolation chroot fedora-working-container ls -a /root
. .. .bash_logout .bash_profile .bashrc .cshrc .tcshrc
$ buildah --storage-driver vfs run --isolation chroot fedora-working-container touch /root/here
$ buildah --storage-driver vfs run --isolation chroot fedora-working-container ls -a /root
. .. .bash_logout .bash_profile .bashrc .cshrc .tcshrc here
# buildah --storage-driver vfs rm fedora-working-container
While buildah generates unique names automatically (fedora-working-container-1, -2, etc.), we should not rely on it - we can just generate an UUID:
uuid=$(uuid -v4)
buildah --storage-driver vfs from --isolation chroot --name atex-$uuid --pull=never 338bec00ee44
A custom chrooting logic could be implemented, but buildah automates image fetching and is established for running chroots for building already, and if the environment changes (ie. podman prohibits bind mounts), it would adjust to that, we don't need to modify anything.
When running in an existing podman/docker container, SELinux + seccomp prevents effective nesting (UID mapping, etc.), but old-school chroots can still be used to somewhat isolate execution.
buildahsupports both puling OCI images and using them via chroots, even for arbitrary command execution (not just building), allowing tests to run in chroots in nicely prepared container images (no need to custom-prepare images).Basically:
buildah pullto fetch the imagebuildah fromto prepare a new rootfs ("start a container")buildah runto run commands in that rootfs as chroot ("podman exec")buildah rmto delete itThere's likely no PID / network / etc. isolation, so this can never be made to support systemd.
While
buildahgenerates unique names automatically (fedora-working-container-1,-2, etc.), we should not rely on it - we can just generate an UUID:A custom chrooting logic could be implemented, but
buildahautomates image fetching and is established for running chroots for building already, and if the environment changes (ie. podman prohibits bind mounts), it would adjust to that, we don't need to modify anything.