Buildah

Buildah for Dockerfile and scripted OCI image builds without a container daemon.

Build from Dockerfile

Build using a standard Dockerfile
buildah bud -t myapp:v1.0 .
buildah bud -t myapp:v1.0 -f Dockerfile.prod .     # specific Dockerfile
buildah bud --no-cache -t myapp:v1.0 .              # force rebuild
buildah bud --layers -t myapp:v1.0 .                # cache intermediate layers

Scripted Builds (No Dockerfile)

Build an image interactively with shell commands
container=$(buildah from alpine:3.19)
buildah run "$container" -- apk add --no-cache nginx
buildah copy "$container" ./nginx.conf /etc/nginx/nginx.conf
buildah config --port 80 "$container"
buildah config --entrypoint '["/usr/sbin/nginx", "-g", "daemon off;"]' "$container"
buildah commit "$container" myapp:v1.0
buildah rm "$container"
Scripted builds give you full shell control over each layer. Useful when Dockerfile syntax is limiting or when you need conditional logic during build.

Image Management

List, inspect, and push images
buildah images                          # list local images
buildah inspect myapp:v1.0              # image metadata
buildah push myapp:v1.0 docker://registry.example.com/myapp:v1.0
buildah push myapp:v1.0 oci-archive:myapp-v1.0.tar   # export to OCI archive
Tag images
buildah tag myapp:v1.0 myapp:latest
buildah tag myapp:v1.0 registry.example.com/myapp:v1.0

Working Containers

Manage build containers
buildah containers                      # list working containers
buildah rm "$container"                 # remove working container
buildah rm --all                        # remove all working containers
Mount container filesystem for direct manipulation
mnt=$(buildah mount "$container")
echo "Container root: $mnt"
cp ./app "$mnt/usr/local/bin/app"       # copy files directly
buildah unmount "$container"

Cleanup

Remove unused build artifacts
buildah prune                           # remove dangling build cache
buildah rmi --all                       # remove all local images