Docker Images
Sign Docker images with cosign
Sign your Docker images after they're pushed.
Config
docker_signs:
- artifacts: all
cmd: cosign
args: ["sign", "--key=cosign.key", "{{ Artifact }}@{{ Digest }}"]Docker sign config fields
| Field | Type | Default | Description |
|---|---|---|---|
id | string | Unique identifier for this docker sign config (referenced by ids filters elsewhere). | |
artifacts | string | "" | Which Docker artifacts to sign: all, images, manifests, none, or "" (empty — the default — signs the canonical Docker images). The singular image / manifest are not accepted and hard-error at release time. none skips only this entry: another docker_signs: entry still runs, and its failure still fails the stage. |
cmd | string | cosign | Signing command to invoke. |
args | list | ["sign", "--key=cosign.key", "{{ .Artifact }}@{{ .Digest }}", "--yes"] | Arguments passed to the signing command. {{ Artifact }} is replaced by the digest-pinned image reference and {{ Signature }} by the synthesized <image>@<digest>.sig name before the rest is rendered as a template; {{ Digest }} renders the image digest. The ${artifact} shell variables the binary/archive path expands are not expanded here and reach the signing command as literal text. |
signature | string | — | Ignored. A container signature is stored in the registry beside the image with no file written, so anodizer synthesizes the <image>@<digest>.sig name its argv substitutes and reads this template nowhere. anodizer check config warns when it is set. |
certificate | string | Certificate file whose presence selects cosign's bundle verification mode. The path itself never reaches the signing command — {{ Certificate }} in args: renders empty. | |
ids | list | all | Only sign images from docker configs whose id is in this list. |
stdin | string | Content written to the signing command's stdin (e.g. a passphrase); rendered as a template (e.g. {{ Env.GPG_PASSPHRASE }}) with nothing substituted first, so neither {{ Artifact }} nor ${artifact} names anything here. The value is a credential: leading and trailing whitespace is removed, and a template that does not render is an error naming docker_signs[<id>].stdin without the template's text. | |
stdin_file | string | Path to a file whose content is written to the signing command's stdin. | |
env | list | Environment variables passed to the signing command (KEY=VALUE strings). Entries render in order; a later one can read an earlier one through .Env. | |
output | bool | false | Capture and log the signing command's stdout/stderr. |
if | string | Template-conditional: skip this config when the rendered value is false, 0, no or empty, in any letter case. An absent, empty or blank if: imposes no gate and always runs; the falsy test applies to what a non-blank gate renders. |
Images are signed one at a time. A keyless config (no --key argument) also
takes the same host-level advisory lock as keyless
binary/archive signing, so two anodizer processes on
one host take turns on the sigstore TUF trust store and do not collide on it.
Job summary
On GitHub Actions, a release appends a Signed image line to the job summary
for every image reference it signed, once per reference, in the order the
images were registered. An image is listed only after its signing command
succeeded and, when anodizer verifies the signature it just attached, after
that verification succeeded too, so a failed sign or a failed verify leaves it
out. A dry run and a snapshot write no job summary at all.
Signed image `ghcr.io/acme/app:1.2.3-amd64`