Linux Command: buildah
Build OCI container images without a daemon
The buildah command builds OCI and Docker container images without requiring a running daemon. Part of the Podman container ecosystem developed by Red Hat, Buildah provides fine-grained control over the image build process โ either using standard Dockerfiles or through scripted builds that manipulate container layers directly. Buildah is particularly valuable in CI/CD pipelines where running a Docker daemon is impractical or a security concern. It can build images as a regular user (rootless), does not require any long-running background process, and produces images compatible with Docker, Podman, Kubernetes, and any OCI-compliant runtime. While podman build uses Buildah internally for Dockerfile-based builds, the buildah CLI adds unique capabilities: scripted builds without Dockerfiles, mounting container filesystems on the host, fine-grained layer control, and the ability to build from scratch (empty) images. This makes Buildah ideal for creating minimal, optimized container images for production.
Syntax
buildah [OPTIONS] COMMAND [ARG...]Key Options
fromโ Create a working container from a base imagerunโ Run a command inside the working containercopyโ Copy files into the working containerconfigโ Set image configuration (CMD, ENV, EXPOSE, etc.)commitโ Create an image from a working containerbud (build-using-dockerfile)โ Build image from Dockerfile
Examples
Scripted build (no Dockerfile)
ctr=$(buildah from alpine:3.19) && buildah run $ctr apk add --no-cache python3 pip && buildah copy $ctr ./app /app && buildah config --cmd "python3 /app/main.py" --port 8080 $ctr && buildah commit $ctr myapp:latestBuild from Dockerfile
buildah bud -t myapp:v1.0 --layers --target production .Build from scratch (empty image)
ctr=$(buildah from scratch) && mnt=$(buildah mount $ctr) && cp mybinary $mnt/ && buildah config --cmd "/mybinary" $ctr && buildah commit $ctr minimal:latestPro Tips
- Buildah builds images without a daemon or root privileges โ perfect for CI/CD pipelines (GitHub Actions, GitLab CI, Jenkins) where running dockerd is impractical.
- podman build is a wrapper around Buildah for Dockerfile builds. Use buildah directly when you need scripted builds, filesystem mounting, or building from scratch.
- Working containers created with buildah from are temporary. Always commit (buildah commit) before removing them, or your work is lost.
Learn more: Full buildah reference โ
Related Resources