Build preview
pycontainer preview answers “what would this build change?” before you build.
It plans the build from the same configuration build uses, serializes the
planned application layer in memory with the builder’s own tar writer, and
compares the result with one explicitly selected baseline image.
pycontainer preview --baseline IMAGE [supported build flags] [--json]Use pycontainer preview --help for the supported planning flags. Configuration
files and declared --build-arg overrides are resolved the same way as build.
Conditional file rules and entrypoint discovery use the same selected files as
the build, including all exclusions.
Preview does not compare manifest or index annotations. Python-version matrix
configurations are not supported; use a single-version configuration for each
image.
Selecting a baseline
Section titled “Selecting a baseline”The baseline is never guessed:
| Baseline | Example | Network |
|---|---|---|
| OCI layout directory | dist/image, oci:./out:v1, oci:./out@sha256:... |
none |
docker save archive |
docker-archive:./app.tar, docker-archive:./app.tar:app:v1 |
none |
| Registry image | docker://ghcr.io/me/app:v1, docker://ghcr.io/me/app@sha256:... |
registry only |
A bare name such as app:v1 is rejected; prefix registry images with
docker://. A multi-platform index is resolved for the single planned
--platform (default linux/amd64); a missing, duplicated, or mismatched
platform is an error. For a multi-platform build configuration, override it
with one target using --platform.
Registry baselines use the same credential providers and registry transport
settings as builds, including --registry-ca-file and --insecure-registry.
When resolving a planned registry base, generic REGISTRY_* destination
credentials are not sent to the base registry. If that base has configured
registry mirrors, preview does not resolve it and reports the base as
unknown; it does not guess whether a mirror would serve different content.
When a required base-image trust policy is configured, preview does not
resolve the planned base or verify the policy and reports the base as
unknown; a subsequent build performs the required verification.
Registry control-request redirects keep credentials only when they stay on the
same scheme, host and port; cross-origin and port-changing redirects drop them.
HTTPS-to-HTTP redirects are rejected. Token-exchange and blob-storage redirects
are always followed without credentials. Manifests are
capped at 16 MiB (or their descriptor size, if smaller) and blobs are verified
against their descriptor digest and size.
What is read and written
Section titled “What is read and written”Only the baseline’s manifest, config, and final layer are read. The final
layer’s DiffID is verified while it is streamed, with the same entry, size and
path-safety limits as pycontainer inspect. Temporary files live in one
temporary directory that is removed before the command returns. Preview never
writes to the build context, output directory, or layer cache, and a local
baseline never opens a network connection. When the planned base is a local
oci:/docker-archive: image, its config is read offline too; a registry base
is resolved only for a docker:// baseline without a configured mirror for
that registry. Neither kind of base is resolved when a required trust policy
is configured.
Planning reads are bounded as well. Project metadata that is loaded whole into
memory (pyproject.toml, the --config file, Python sources scanned for
framework defaults, and the Docker credential config) is limited to 16 MiB per
file. This limit is shared with build: an oversized file of any of these
kinds is an explicit error rather than being skipped, so framework detection
never silently selects a different entrypoint and an oversized credential file
never falls back to unauthenticated access.
Application files are streamed through a hash, never held in memory, and the
planned application layer is limited to 100,000 files and 64 GiB.
Selection uses the build’s symlink and credential checks; when staging from
requirements, local included requirement files are checked without running pip.
If a selected file cannot be represented in the tar, preview and build fail
instead of omitting it.
No user code, pip, or container runtime is executed.
Provenance
Section titled “Provenance”File-level changes depend on identifying the baseline’s application layer:
| Level | Evidence | Reported |
|---|---|---|
exact |
The planned app layer DiffID equals the baseline’s final DiffID (reproducible builds without planned dependency squashing only). | No file changes. Application is identical. |
positional |
The planned base DiffIDs are the baseline’s lower layers, followed by one or two layers, and the final layer has the shape of an app layer. | File changes marked inferred; application and dependencies unknown. |
inferred |
Only the final layer’s shape matches: regular files, symlinks and hardlinks under the baseline WorkingDir, without directories, whiteouts or .python dependency paths. |
File changes marked inferred; application and dependencies unknown. |
none |
No application layer could be identified. | Files and application unknown. |
Files are compared by type, content digest, size, mode, owner, and link target.
A WorkingDir change appears as deleted plus added paths. The root working
directory (/) is supported.
An observed squash-history marker also prevents positional or inferred
identification. Positional and shape-based results are not recorded
provenance: an unmarked layer can contain both dependencies and app files.
Settings
Section titled “Settings”When the planned base config is known, the planned image config is computed
as build computes it, and WorkingDir, Entrypoint, Cmd, User,
ExposedPorts, StopSignal, Volumes, Healthcheck, each Env variable,
and each label (including release notes) are compared. When the base is not
resolved, inherited values and the merged volume set are unknown.
Environment values are always shown as <redacted>, so only the status reveals
that a value changed. The CLI also redacts declared build-argument values in
its report and errors.
Accuracy limits
Section titled “Accuracy limits”- Base layers are compared by the DiffIDs their configs declare; base blobs are not downloaded or verified.
- With
--include-deps, dependencies are resolved at build time, so the dependency component and thePATH/PYTHONPATHsettings areunknown. - With both
--include-depsand--squash, the final layer may combine dependencies and application files. The application component and file comparison areunknown, andappLayerDiffIdisnull. - Preview does not verify signature policies, scan images, or run containers.
A configured base-image trust policy leaves the planned base
unknown. - Non-reproducible builds (
--no-reproducible) embed modification times and can reuse a cached layer, so provenance is neverexactand the application component isunknown, even when inferred file changes are found. - The plan is a fresh application layer. The layer cache key includes the
hardlinks a fresh layer emits, so a cache-enabled
buildreuses a cached layer only when its hardlink topology matches.--no-cachepreviews a cache-free build. - Modification times are not compared.
- The exit code is
0for a report and1for any error; errors never produce a partial report.