mjl.
← All articles

Podman Images, Commit, Export, and Import

podmancontainersimagesbackup

Follow Installing Podman and Understanding Containers first. Prefer a Containerfile for reproducible builds; commit is useful for an experiment but records an opaque snapshot of a container.

Commit an experimental container

podman run --name alpine-lab --detach alpine:3.20 sleep infinity
podman exec alpine-lab apk add --no-cache curl
podman commit alpine-lab localhost/alpine-lab:0.1
podman images

The installed package is now part of the committed image, but the command, provenance, and exact build steps are not as clear as a Containerfile. Stop and remove the temporary container when finished.

Save and load an image

podman save --format oci-archive \
  --output alpine-lab-0.1.tar localhost/alpine-lab:0.1
sha256sum alpine-lab-0.1.tar
podman load --input alpine-lab-0.1.tar

podman save preserves an image and its layers. It is appropriate for moving an image between hosts without a registry. Treat the archive as sensitive if it contains application files or embedded credentials.

Export and import a container filesystem

podman export --output alpine-rootfs.tar alpine-lab
podman import alpine-rootfs.tar localhost/alpine-rootfs:0.1

Export does not preserve image history, configuration, volumes, or the original container metadata. It is not a complete backup strategy.

For remote transfer, use SSH as described in Linux SSH and Secure File Transfer, then verify the checksum on the destination.