LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

podman-build

Build container images from Containerfiles

TLDR

Build from Containerfile in current directory
$ podman build -t [image:tag] .
copy
Build with specific Containerfile
$ podman build -f [Containerfile.dev] -t [image:tag] [path]
copy
Build without cache
$ podman build --no-cache -t [image:tag] [path]
copy
Build with build args
$ podman build --build-arg [KEY=value] -t [image:tag] [path]
copy
Build a specific stage of a multi-stage build
$ podman build --target [stage_name] -t [image:tag] [path]
copy
Build for a specific platform
$ podman build --platform [linux/arm64] -t [image:tag] [path]
copy

SYNOPSIS

podman build [options] context

DESCRIPTION

podman build creates container images from a Containerfile (or Dockerfile) in the specified build context directory. It is compatible with Docker build syntax and supports multi-stage builds, build arguments, and layer caching.Under the hood, it uses Buildah for the actual image building process. The output is an OCI-compliant container image by default.

PARAMETERS

CONTEXT

Build context directory or URL.
-t, --tag NAME
Image name and optional tag (name:tag).
-f, --file FILE
Containerfile path. Use -f - to read from stdin.
--no-cache
Do not use existing cached images for building. Rebuild all layers.
--build-arg ARG
Build-time variables in KEY=value format.
--pull
Always pull the base image even if a local copy exists. Accepts always, missing, never, or true/false.
--squash
Squash all newly built layers into a single layer.
--target STAGE
Set the target build stage in a multi-stage Containerfile.
--platform OS/ARCH
Set the OS/architecture of the built image (e.g., linux/arm64, linux/amd64).
--layers
Cache intermediate images during the build process (default true).
--format FORMAT
Image manifest and metadata format (oci or docker).
--label LABEL
Add a label to the image in KEY=value format.

CAVEATS

Uses Buildah under the hood. Largely compatible with Docker build, but some Docker-specific features may behave differently. The default image format is OCI, unlike Docker which defaults to the Docker format. Use --format docker for Docker compatibility.

SEE ALSO

Copied to clipboard
Kai