Buildah: build OCI container images from a Containerfile
Learn how Buildah turns a Containerfile or scripted steps into an image, how to inspect the result, and when to use it alongside Podman.
Buildah: build OCI container images from a Containerfile
Buildah is a Linux command-line tool focused on creating and exporting container images. It can build an existing Containerfile or Dockerfile, or assemble an image from commands such as from, run, copy, config, and commit. Like Podman, its normal workflow does not require a central daemon, but its main job is image construction rather than managing long-running application containers.
What problem does Buildah solve?
An image build selects a base filesystem, adds files and packages, sets runtime configuration, and saves the result as an image. Buildah provides both a declarative path through a Containerfile and a command-driven path for scripts that need to assemble steps dynamically. It can produce OCI or Docker image formats. Images can then be pushed to a registry or transferred using supported image-copy workflows.
Buildah versus Podman
The projects complement each other. A Buildah working container is an intermediate filesystem used to construct an image. buildah run is similar to a Containerfile RUN step. Podman focuses on creating and managing containers intended to run applications; podman run is closer to starting an application container. Podman can build Dockerfiles through Buildah libraries, so a separate Buildah CLI is not always needed for that feature. Storage configuration can differ, so do not assume a working container created by one tool appears in the other's container list. Plan image transfer using the configured stores and explicit push, pull, or export steps.
Build and inspect a first image
This documented example assumes Buildah is installed on a Linux development host and can pull a base image. Create a folder named app and put this in its Containerfile:
FROM docker.io/library/alpine:latest
RUN printf 'Buildah image works\n' > /hello.txt
CMD ["cat", "/hello.txt"]Build the current directory as context and tag the image:
buildah build -t localhost/hello:1.0 .The final dot selects the current directory as build context: the set of files available to build instructions. For COPY, source paths must stay within that context. Check the result with buildah images and buildah inspect localhost/hello:1.0. A matching tag and image configuration indicate that the image is in local storage. This is a documentation-based example, not a claim that it was executed here. The latest tag can point to different content later; use an approved version tag or digest when repeatability matters.
Build without a Containerfile
You can create a working container from a base image with buildah from, add files with buildah copy, set runtime configuration with buildah config, and create an image with buildah commit. This is useful when another language or automation tool needs to generate build steps. Keep inputs, error handling, and final image settings explicit because the procedure otherwise becomes scattered across commands.
A scratch working container has no ordinary shell or package manager. Add the filesystem contents and executable dependencies the application needs; do not assume package installation will work. Check for dynamic libraries, certificates, and user configuration before relying on a minimal image.
Rootless operation and troubleshooting
Buildah can run as a non-root user, but user namespaces, subordinate UID/GID ranges, storage drivers, and networking requirements vary by distribution and environment. The official tutorial points rootless users to the same family of setup requirements as Podman. Check buildah info, buildah images, and buildah containers first. For mount or permission errors, review the system's rootless setup and the documented buildah unshare conditions. Repeating every command with sudo can switch to a different image store and make earlier work appear missing; confirm which user's storage you are inspecting before elevating privileges.
When should you choose Buildah?
Choose it when image construction, filesystem control, or programmable build steps are the main task. Use an engine such as Podman when the next task is to run and manage long-lived containers or Pods. Kubernetes node runtimes such as CRI-O or containerd serve kubelet's CRI requests; Buildah is neither a scheduler nor a node runtime. Compare Podman's execution model and the OCI image format for the boundaries between these tools and artifacts.
Sources and scope
Buildah README and Podman relationship · official introductory tutorial · buildah build manual
Based on official Buildah documentation reviewed on 22 November 2026. Installation, rootless prerequisites, and storage behavior depend on distribution and configuration.