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
