Multiple tags
One build can publish the same image under several tags. Layers, the config
blob, and the manifest are built once; with --push, blobs are uploaded once
and the manifest is pushed once per tag.
pycontainer build --push \ --tag ghcr.io/me/app:v1.2.3 \ --tag ghcr.io/me/app:stable--tag is repeatable. The first value is the primary tag (used for the build
result and as the default push target) and must be a full reference. Later
values may be full references in the same repository or bare tags, for example
--tag ghcr.io/me/app:v1 --tag v2.
Semantic version expansion
Section titled “Semantic version expansion”pycontainer build --tag ghcr.io/me/app:v1.2.3 --semver-tags --latest| Flag | Effect |
|---|---|
--semver-tags |
v1.2.3 also gets v1.2 and v1 (a v prefix is optional) |
--latest |
also adds latest (opt-in, never implicit) |
Pre-release versions such as v1.2.3-rc1 are not expanded. Using
--semver-tags when no tag looks like MAJOR.MINOR.PATCH is an error.
Git-derived versions
Section titled “Git-derived versions”pycontainer build --context . --tag ghcr.io/me/app \ --tag-from-git --semver-tags --latest--tag-from-git replaces the version of the first image reference with the
result of git describe --tags --exact-match for the context’s HEAD. Other
explicit tags remain in the same repository and participate in expansion as
usual. If multiple Git tags point at HEAD, Git selects the exact match.
Branches and tags on ancestor commits do not count.
Git and an existing worktree with a HEAD commit are required. If HEAD has no
exact tag, --git-fallback sha opts into sha- followed by the first 12
characters of the commit ID; otherwise the build fails. Git tags that are not
valid OCI tags are rejected rather than rewritten. A SHA fallback is not a
semantic version, so --semver-tags requires another stable version tag.
Tracked changes, staged changes and untracked files anywhere in the Git
worktree cause an error unless --allow-dirty is explicitly supplied. As with
Git status, ignored files are not considered dirty; ensure they cannot affect
the image if it must correspond to the commit. Git is inspected again when
the build starts; a changed HEAD or selected tag requires a new configuration.
Before publishing the local layout, HEAD and the selected Git tag are checked
again, and the worktree must still be clean unless --allow-dirty was supplied.
Untracked files generated by this build in the output and cache locations and
the builder’s output lock file are excluded from this final cleanliness check;
tracked changes there are still detected. The checks do not freeze source files,
so do not modify the worktree during a build. Before each registry tag is
published, an exact Git tag must still point at the built commit;
checking out another commit after a successful build does not change the image
being pushed. No Git tag is created or moved.
With --registry, omit the destination’s tag or use the same Git-derived
version; a conflicting tag or digest is rejected.
Configuration file
Section titled “Configuration file”[build]tag = "ghcr.io/me/app:v1.2.3"tags = ["stable", "ghcr.io/me/app:prod"]semver-tags = truelatest-tag = trueOn the command line, any --tag replaces both tag and tags from the file.
Git-derived tagging can also be enabled in the file:
[build]tag = "ghcr.io/me/app"tag_from_git = truegit_fallback = "sha" # optionalDirty worktrees require the command-line --allow-dirty opt-in; it cannot be
enabled in the configuration file.
Validation
Section titled “Validation”- Tags must match the registry tag syntax (
[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}). - Every full reference must target the same registry and repository as the primary tag; otherwise the build fails with a message naming both.
- Digest references are rejected.
- Duplicates are removed.
Output
Section titled “Output”The layout’s index.json has one descriptor per tag, pointing to a manifest
for single-platform builds or an image index for multi-platform builds. Every
descriptor has the same digest and size, and its
org.opencontainers.image.ref.name annotation is the reference to select.
Names use the primary’s repository spelling. For example,
--tag myapp:v1.2.3 --tag stable produces
myapp:v1.2.3 and myapp:stable, and --tag ghcr.io/me/app:v1.2.3 --semver-tags produces ghcr.io/me/app:v1.2.3, ghcr.io/me/app:v1.2 and
ghcr.io/me/app:v1. Single-platform layouts also name the primary descriptor
at the index level.
Opt-in signed pushes stage and verify the immutable manifest or image index,
then sign and verify it before writing any requested tag. Each acknowledged
tag write is read back; a failed write or mismatched readback stops subsequent writes and
reports acknowledged, unknown, and unattempted references. An acknowledgement
or successful readback is not a guarantee against a later concurrent retag.
With --tag-from-git, the selected Git tag is rechecked before each requested
tag write, including after signing; a changed Git tag stops subsequent writes.
Signature-storage fallback tags cannot also be requested image tags. See
image signing for provider-specific limitations.
Standard OCI tools select an image by that annotation:
skopeo inspect oci:dist/image:ghcr.io/me/app:v1.2.3skopeo copy oci:dist/image:ghcr.io/me/app:v1 docker-daemon:ghcr.io/me/app:v1With a single tag, oci:dist/image without a reference also works. With
several tags, standard tools such as Skopeo require an explicit reference,
even though every descriptor points to the same image. Bare tag names such as
oci:dist/image:stable are not descriptor references.
Some valid registry tags do not satisfy the OCI reference-name grammar. For
these, the layout reference is pycontainer- followed by lowercase hexadecimal
UTF-8 bytes of the complete reference in the primary’s repository spelling.
For example, myapp:_dev becomes pycontainer-6d796170703a5f646576:
skopeo inspect oci:dist/image:pycontainer-6d796170703a5f646576In the unlikely event an encoded name collides with another descriptor name,
0 is appended until it is unique. Inspect index.json for the exact
reference. Registry tags and refs/tags filenames retain their original values.
The layout also gets one refs/tags/<tag> file per tag, all pointing at the
same manifest or index digest; standard tools do not read these files. After a push,
builder.pushed_refs lists every pushed reference. Registry pushes publish
each tag separately and are unaffected by the layout index. For multi-platform
pushes, a later tag failure reports confirmed, failed or unknown-outcome, and
unattempted references; previously pushed tags are not rolled back.