Buildah is an open-source command-line tool for building container images that conform to the Open Container Initiative (OCI) and Docker image formats. Unlike the classic Docker build, it needs no background daemon and can run without root privileges, which makes it a common choice for secure image builds in containers and cloud CI pipelines.
Buildah was started by Red Hat and belongs to the same family of tools as Podman and Skopeo. It can build images from a Dockerfile or Containerfile, but it also exposes individual build steps as commands, so images can be assembled from shell scripts without any Dockerfile at all.
How Buildah builds images without a daemon
Buildah builds an image by creating a working container, modifying its filesystem and then committing it as an image layer. Each step runs as an ordinary process started by the user, not by a privileged service, so there is no long-running daemon and no Docker socket that grants root-equivalent access.
Storage is handled by the containers/storage library, which typically uses the overlay filesystem driver and keeps images in the user’s home directory for rootless builds. In rootless mode, Buildah relies on user namespaces: the user appears as root inside the build, while files map to unprivileged subordinate UIDs defined in /etc/subuid and /etc/subgid.
The most important Buildah subcommands map directly onto the stages of an image build.
| Command | What it does | Dockerfile equivalent |
|---|---|---|
| buildah from | Creates a working container from a base image | FROM |
| buildah run | Executes a command inside the working container | RUN |
| buildah copy | Copies files from the host into the container | COPY |
| buildah config | Sets metadata such as entrypoint, env and labels | ENTRYPOINT, ENV, LABEL |
| buildah mount | Mounts the container filesystem on the host | No direct equivalent |
| buildah commit | Saves the container as a new image | End of build |
| buildah bud | Builds from a Dockerfile or Containerfile | docker build |
Building with and without a Dockerfile
Buildah supports two styles of building. The command buildah build (historically buildah bud, short for build-using-dockerfile) reads a Dockerfile and produces the same result a Docker build would, including multi-stage builds. This path makes migration from Docker almost effortless.
The second style is scripted building. A shell script calls buildah from, buildah run and buildah commit in sequence, with full access to loops, conditionals and host tools. Combined with buildah mount, a script can install files with the host package manager directly into the image, producing minimal images without shells or package managers inside them, similar to a distroless image.
| Aspect | Dockerfile build | Scripted build |
|---|---|---|
| Portability | Works with Docker, Podman and Kaniko | Requires Buildah on the build host |
| Logic | Limited to Dockerfile instructions | Full shell logic and host tools |
| Layer control | One layer per instruction by default | Layers created only on commit |
| Image size | Depends on base image tooling | Can omit shells and package managers |
| Readability | Familiar to most teams | Requires reading shell code |
Buildah compared with Docker and Podman
Buildah focuses only on building images, while related tools cover running containers or other build environments. Podman actually uses Buildah’s code for its own podman build command, so the two produce identical images; Buildah simply offers finer-grained control over each step.
| Tool | Daemon required | Rootless builds | Main purpose |
|---|---|---|---|
| Buildah | No | Yes | Building OCI and Docker images |
| Docker with BuildKit | Yes, dockerd | Possible in rootless mode | Building and running containers |
| Podman | No | Yes | Running containers, builds via Buildah code |
| Kaniko | No | Runs as root inside its container | Builds inside Kubernetes pods |
| BuildKit standalone | Yes, buildkitd | Yes, with rootless buildkitd | High-performance parallel builds |
Buildah outputs standard images that any OCI-compliant runtime can run, whether runc, crun or containerd, and it pushes them to any container registry with buildah push.
Using Buildah in CI pipelines
Buildah is especially valuable in continuous integration, where mounting the Docker socket into a build job effectively gives that job root access to the host. With Buildah, a CI runner can build images inside an unprivileged container, which reduces the attack surface of shared build infrastructure.
- Use the vfs storage driver or fuse-overlayfs when overlay is unavailable inside a nested container.
- Set
--isolation chrootfor builds inside containers that cannot create new namespaces. - Enable layer caching with
--layersto reuse unchanged layers between builds. - Use
--squashto merge layers when a single compact layer matters more than cache reuse. - Sign or scan the resulting image before pushing, because a rootless build is not automatically a secure image.
Limitations and common pitfalls
Rootless operation brings practical constraints that teams should plan for. The table below lists the most frequent problems and their usual fixes.
| Symptom | Likely cause | Fix |
|---|---|---|
| Permission denied on files | Missing subuid or subgid ranges | Add ranges to /etc/subuid and /etc/subgid |
| Very slow builds | Fallback to the vfs driver | Enable overlay or fuse-overlayfs |
| Cannot bind ports below 1024 | Rootless network limits | Use higher ports or adjust sysctl |
| Cache not reused | Layer caching not enabled | Build with –layers |
| Fails on macOS or Windows | Buildah needs a Linux kernel | Use a Linux VM or Podman machine |
Buildah is Linux-only and its scripted builds are less familiar than Dockerfiles, so teams that need broad portability usually keep a Dockerfile as the source of truth and use Buildah only as the build engine.
A non-technical view
A container image is like a packed lunchbox for software: it holds the program and everything it needs, ready to be opened on any computer.
Buildah is a tool for packing those lunchboxes. Older tools needed a permanent helper with master keys running in the background. Buildah does the packing itself, with only the permissions of the person using it. That makes it safer for shared build machines, where many teams work side by side.
A concrete example
A platform team runs a shared GitLab CI cluster on Kubernetes for about 40 development teams. The old pipeline mounted the Docker socket into build jobs, which meant any build job could take over its node. Security review flagged this as a critical risk.
The team replaces Docker builds with rootless Buildah running in unprivileged pods, using fuse-overlayfs storage and buildah build --layers with the existing Dockerfiles. For a Go service, a scripted build mounts an empty scratch container, copies in the static binary and CA certificates, and commits an image of about 15 MB instead of the previous 300 MB.
After the migration, no build job needs privileged access, average build times stay within 10 percent of the previous pipeline thanks to layer caching, and the cluster passes its next security audit without exceptions for the CI system.