liveBook · Manning

Podman build

As explained in Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more

podman build is a Podman command that constructs a container image from a Containerfile and build context.

podman build constructs an OCI container image from a Containerfile and a context directory. The Containerfile defines the build steps, while the context supplies files that directives such as COPY add to the image. section 2.3.1 section 2.3.2

Every Containerfile begins with FROM, which selects a base image or scratch. Podman mounts that image as a rootfs using copy-on-write storage; COPY adds files, and RUN executes commands in the image under the same security constraints as podman run. Each RUN result becomes the input for the next step. section 2.3.1 section 2.3.1

Use podman build to:

  • Build reproducibly from scripted Containerfile instructions instead of committing a modified container. section 2.1.9 section 2.4
  • Tag the resulting image with -t, then push it to a container registry. section 2.3.2
  • Rebuild applications through CI/CD or cron jobs, test replacements, and prune dangling images when old tags become unassigned. section 2.3.2

Build a small web image

Place index.html and a Containerfile in myapp. Define FROM ubi8/httpd-24 and COPY index.html /var/www/html/index.html, then run podman build -t quay.io/rhatdan/myimage ./myapp. The completed image is tagged and ready for podman push. section 2.3.2

How Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more covers it

How deep it goes
Explains rootfs, copy-on-write storage, build layers, directives, tagging, automation, and cleanup, but not advanced build features.
Examples
Demonstrates a UBI Apache image that copies index.html, tags the result, pushes it, and replaces an older image.
What it assumes
Assumes basic Podman command-line use while defining Containerfiles, contexts, base images, and build directives.
What you can do after
Build it from scratch, automate rebuilds, tag images, push them to registries, and remove dangling predecessors.
How it connects
Connects Containerfiles, Dockerfiles, OCI images, root filesystems, container registries, CI/CD, and podman run.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more. The section links point to the parts of the book it draws on.