$ run as a normal user# run as root (or with sudo)
Know it before you install
Buildah creates a working container from a base image, changes it (run commands, copy files, set config) and commits it as an image — or simply builds a Containerfile/Dockerfile. Skopeo talks to registries with transports: docker:// (a registry), oci:/dir: (local folders), oci-archive:/docker-archive: (tar files), containers-storage: (Podman/Buildah storage).
Install on RHEL, Rocky, Alma and Fedora
Install on Ubuntu and Debian
apt-get update
apt-get install -y buildah skopeo uidmapRootless use needs sub-UIDs for your user (see the Podman guide: /etc/subuid, /etc/subgid).
First configuration: log in and build
buildah login harbor.example.com
buildah build -t harbor.example.com/shop/api:1.4.0 -f Containerfile .
buildah images
buildah push harbor.example.com/shop/api:1.4.0A small, safe image (multi-stage, non-root user):
FROM registry.access.redhat.com/ubi9/python-312 AS build
WORKDIR /opt/app-root/src
COPY requirements.txt .
RUN pip install --no-cache-dir --target /opt/deps -r requirements.txt
COPY app/ app/
FROM registry.access.redhat.com/ubi9/python-312
COPY --from=build /opt/deps /opt/deps
COPY --from=build /opt/app-root/src/app /opt/app-root/src/app
ENV PYTHONPATH=/opt/deps
USER 1001
EXPOSE 8080
CMD ["python", "-m", "app"]The scripted way — useful when you do not want a Containerfile, or need logic between steps:
ctr=$(buildah from registry.access.redhat.com/ubi9/ubi-minimal)
buildah run $ctr -- microdnf -y install nginx
buildah run $ctr -- microdnf clean all
buildah copy $ctr ./site /usr/share/nginx/html
buildah config --port 8080 --user nginx --cmd "nginx -g 'daemon off;'" --label org.opencontainers.image.source=https://github.com/ORG/site $ctr
buildah commit --rm $ctr harbor.example.com/web/site:1.0.0Buildah in CI (no privileges)
In a container-based CI job (GitLab, GitHub, Tekton), Buildah runs without --privileged with the chroot isolation and the vfs storage driver:
build-image:
stage: build
image: quay.io/buildah/stable
variables:
STORAGE_DRIVER: vfs
BUILDAH_ISOLATION: chroot
script:
- buildah login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- buildah build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" .
- buildah push --digestfile digest.txt "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
artifacts:
paths: [digest.txt]--digestfile saves the pushed digest — sign and scan exactly that digest in the next jobs.
Skopeo: inspect, copy, sync
skopeo inspect docker://docker.io/library/nginx:1.27 | jq '.Digest, .Created, .Architecture'
skopeo inspect --format '{{.Digest}}' docker://harbor.example.com/shop/api:1.4.0
skopeo list-tags docker://harbor.example.com/shop/api
skopeo copy --all docker://docker.io/library/nginx:1.27 docker://harbor.example.com/mirror/nginx:1.27
skopeo copy docker://harbor.example.com/shop/api:1.4.0 docker://harbor.example.com/shop-prod/api:1.4.0
skopeo copy docker://docker.io/library/alpine:3.22 oci-archive:alpine-3.22.tar
skopeo sync --src docker --dest dir docker.io/library/redis:7 /srv/mirror/
skopeo delete docker://harbor.example.com/shop/api:old-test| Command | Use |
|---|---|
inspect | Digest, labels, architecture — without pulling. |
copy --all | Copy every architecture of a multi-arch image. |
copy between projects | Promote a tested image from staging to prod registry (same digest). |
copy … oci-archive: / sync … dir | Move images into air-gapped networks. |
delete | Remove a tag/manifest from a registry. |
Real uses at work:
- Rootless, daemonless image builds in CI and on RHEL servers.
- Promotion of tested images between registries; mirroring public images to Harbor/Nexus.
- Air-gapped clusters: export to archives, import on the other side.
Make it safe
Security checklist:
- Build rootless and without
--privileged(chroot isolation in CI). - Fully qualified base images (
registry.access.redhat.com/ubi9/...,docker.io/library/...), pinned tags or digests. - Non-root
USER, multi-stage builds, no secrets in layers (use--secretfor build-time secrets). - Push by digest, then scan (Trivy) and sign (Cosign) that digest.
- Registry credentials only from CI secrets;
auth.jsonprivate. - Use
policy.jsonto require signatures for production registries where possible.
Update and remove
Fix common problems
| Problem | Cause | Fix |
|---|---|---|
short-name resolution enforced but cannot prompt | Base image without a registry name. | Use the full name (docker.io/library/…). |
cannot clone: Operation not permitted / user namespaces errors in CI | The runner blocks user namespaces. | BUILDAH_ISOLATION=chroot, STORAGE_DRIVER=vfs; or allow user namespaces on the runner. |
there might not be enough IDs available | No sub-UIDs for the user. | Add /etc/subuid and /etc/subgid entries; podman system migrate. |
unauthorized: authentication required | Not logged in, or another auth file. | buildah login / skopeo login; check REGISTRY_AUTH_FILE. |
manifest unknown | Wrong tag or the image has only other architectures. | skopeo list-tags; skopeo inspect --raw to see the manifest list. |
| Build very slow in CI | vfs storage copies every layer. | Normal for vfs; use overlay with fuse-overlayfs when the runner allows it; cache base images. |
Next steps
- Quick how-to: Copy images between registries with Skopeo.
- Command pages: buildah, skopeo, podman.
- At work: Buildah — build images in CI safely, Skopeo — copy and inspect images, Make images small and fast.
- After the build: Trivy, Cosign, Harbor.
1Why use Buildah instead of Docker-in-Docker in CI?
Buildah needs no daemon and no privileged container, so a job can not take over the runner host.
2How do you move a tested image from the staging to the production registry without rebuilding it?
skopeo copy docker://staging/... docker://prod/... — the digest stays the same.