Buildah — Daemonless OCI Image Builder
Builds OCI-compliant container images without a daemon, without root, and without a Dockerfile when you want scripted builds.
What it is
Buildah is a command-line tool for building OCI-compliant container images. Unlike Docker, Buildah does not require a running daemon and can build images without root privileges. It supports standard Dockerfiles but also offers an imperative scripting mode where you build images step-by-step using shell commands.
Buildah targets container developers and CI/CD pipelines that need secure, daemonless image builds. It pairs with Podman (for running containers) and Skopeo (for moving images between registries) as part of the container tools ecosystem maintained by Red Hat.
How it saves time or tokens
Buildah's imperative mode lets you build images with fine-grained control. Instead of writing a Dockerfile with workarounds for caching and multi-stage builds, you script the build directly. This is useful for complex build processes that are awkward to express in Dockerfile syntax.
Daemonless, rootless builds mean you can run Buildah in CI environments without privileged containers, simplifying security compliance.
How to use
- Build from a Dockerfile:
buildah bud -t myapp:latest .
- Build imperatively without a Dockerfile:
ctr=$(buildah from ubuntu:22.04)
buildah run $ctr -- apt-get update
buildah run $ctr -- apt-get install -y python3
buildah copy $ctr ./app /opt/app
buildah config --cmd '/opt/app/start.sh' $ctr
buildah commit $ctr myapp:latest
- Push to a registry:
buildah push myapp:latest docker://registry.example.com/myapp:latest
Example
A CI-friendly build script with caching:
#!/bin/bash
set -e
# Create working container from base
ctr=$(buildah from golang:1.22)
# Copy source and build
buildah copy $ctr . /src
buildah run $ctr -- sh -c 'cd /src && go build -o /app'
# Create minimal runtime image
runtime=$(buildah from gcr.io/distroless/static:latest)
buildah copy --from $ctr $runtime /app /app
buildah config --entrypoint '["app"]' $runtime
buildah commit $runtime myapp:latest
This achieves a multi-stage build without Dockerfile syntax.
Related on TokRepo
- AI tools for DevOps -- Container and infrastructure tools
- AI tools for automation -- Build automation for CI/CD pipelines
Common pitfalls
- Forgetting to clean up working containers. Each
buildah fromcreates a working container. Usebuildah rm --allto clean up after builds. - Not using
--layersfor Dockerfile builds. Without layer caching, every build starts from scratch. Usebuildah bud --layersto enable Docker-style layer caching. - Mixing Buildah and Docker image stores. Buildah and Docker use separate image stores by default. Use Skopeo to copy images between them if needed.
Frequently Asked Questions
Buildah does not require a daemon process. It builds images as a regular user process without root privileges. Buildah also supports imperative (scripted) builds in addition to Dockerfiles, giving you more control over the build process.
Yes. The 'buildah bud' (build-using-dockerfile) command is fully compatible with standard Dockerfiles and Containerfiles. Existing Dockerfiles work without modification.
Yes. Buildah and Podman share the same image store. Images built with Buildah are immediately available to Podman for running. They are complementary tools: Buildah builds, Podman runs.
Yes. Buildah supports rootless builds using user namespaces. This is the recommended mode for CI/CD environments where running as root is a security concern.
Buildah pushes to any OCI-compliant registry: Docker Hub, GitHub Container Registry, Amazon ECR, Google Artifact Registry, and private registries. Use 'buildah push' with the registry URL.
Citations (3)
- Buildah GitHub— Buildah builds OCI-compliant container images without a daemon
- Open Container Initiative— OCI image specification for container images
- Buildah Documentation— Rootless container builds for security
Related on TokRepo
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.