Skip to content

imglife scan

imglife scan [path] [flags]

Run in the CI pipeline of any project. scan walks the checkout (default: current directory), extracts every container image reference, classifies it against the base-images imglife.yaml, checks the managed ones like imglife check does and, with --register, publishes the inventory to the Package Registry. The inventory feeds status, cleanup, eol and app.

Flag Default Description
--exclude glob Ignore matching files or directories (repeatable)
--var KEY=VALUE Value of a variable; overrides every other source (repeatable)
--field key=value Custom metadata shown in the status README; overrides fields: (repeatable)
--produces image Image built and pushed by the project; OCI labels are read (repeatable)
--register false Publish the inventory to the Package Registry
--project string $CI_PROJECT_PATH Project path; required with --register
--ref string $CI_COMMIT_TAG, else $CI_COMMIT_REF_NAME Branch or tag scanned
--revision string $CI_COMMIT_SHA Git commit SHA
--source string $CI_PROJECT_URL Project URL, linked from the status README
--config-url string Raw URL of the base-images imglife.yaml (overrides auto-derive)
--eol-data-url string Raw URL of eol-data.yaml
--strict false See exit codes
--warn false Always exit 0
--output string text text or json (the usage record)

Malformed --var / --field values (no =) are ignored with a warning.

Terminal window
# Print the inventory of the current project
imglife scan
# Scan and register from a GitLab CI job
imglife scan --register --produces "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" \
--field team=backend --field env=production
# Ignore example folders, provide a value the scan cannot resolve
imglife scan --exclude "examples/" --var PY_TAG=3.12.9-spe1.0.0
# Machine-readable inventory
imglife scan --output json
Source Extracted
Dockerfile, Dockerfile.*, *.Dockerfile, Containerfile FROM (stage names and scratch skipped), COPY/ADD --from=<image>
devcontainer.json, .devcontainer.json image; build.args are passed on to Dockerfiles
docker-compose*.yml, compose*.yaml services.*.image (with the sibling .env); build.args are passed on to Dockerfiles
.gitlab-ci.yml and its local: includes image, services, default:; global and job variables, extends:; --build-arg in scripts
kustomization.yaml images[] (newName, newTag, digest); the rewritten name is no longer reported from the manifests
Helm values*.yaml (next to a Chart.yaml) image: {registry, repository, tag, digest}; an empty tag defaults to the chart appVersion
Other YAML (Kubernetes manifests…) any image key
Terraform *.tf string literals and image = var.x; only references to managed images are kept

Invalid YAML (Helm templates) and references containing {{ are skipped. Hidden CI jobs (.template) are reported through the jobs that extend them.

Supported forms: $VAR, ${VAR}, ${VAR:-default}, ${VAR-default}, ${VAR:?msg}, $$, and Terraform ${var.x} / ${local.x}. Resolution is recursive.

Precedence, highest first:

  1. --var
  2. vars: of .imglife-scan.yaml
  3. build args collected from CI scripts (--build-arg), compose and devcontainer build.args — for Dockerfiles
  4. values declared by the file itself: ARG defaults, CI variables (job, then global), compose .env, Terraform defaults, terraform.tfvars, *.auto.tfvars, literal locals
  5. the job environment (CI_* predefined variables, project and group variables)

A typical split reference — the CI holds the image, the Dockerfile only an ARG:

.gitlab-ci.yml
variables:
BASE_IMAGE: registry.example.com/bases/alpine:3.21.3-core1.0.0
build:
script:
- docker build --build-arg BASE_IMAGE="${BASE_IMAGE}" .
ARG BASE_IMAGE
FROM ${BASE_IMAGE}

scan reports registry.example.com/bases/alpine:3.21.3-core1.0.0 as a base image, source Dockerfile:2.

Kind Rule
base repository produced by a build.images block (exact match, then ignoring the registry host)
mirror target of a sync entry (same rule)
applicative starts with one of scan.applicative_prefixes
unmanaged any other valid reference (public images, CI tooling…)
unresolved the repository still contains an unresolved variable

A reference whose repository resolves but whose tag does not (…/python:${PY_TAG}) keeps its kind with the status unknown. References are deduplicated; each image lists all its file:line sources.

Optional, at the scan root:

exclude: # ignored globs (on top of scan.exclude and --exclude)
- "examples/"
- "**/testdata/**"
vars: # values of variables the scan cannot resolve
PY_TAG: 3.12.9-spe1.0.0
images: # images that cannot be detected, declared by hand
- registry.example.com/mirrors/redis:7.4
fields: # custom metadata (status README, app list)
team: backend

Exclusion patterns follow gitignore: *, ?, [abc], **; a pattern without / matches at any depth, a leading / anchors it to the root, a trailing / restricts it to directories. Negation (!) is not supported. .git/, node_modules/, vendor/ and .terraform/ are always excluded.

KIND STATUS IMAGE SOURCES
base update (3.21.4-core1.0.0) registry.example.com/bases/alpine:3.21.3-core1.0.0 Dockerfile:2
mirror ok registry.example.com/mirrors/postgres:16.4 .gitlab-ci.yml:12 k8s/deploy.yaml:20
unmanaged - docker:26-dind .gitlab-ci.yml:51
5 file(s) scanned, 3 image(s) — worst status: update — result: OK

Statuses: ok, update, warning, critical, eol, unknown (check impossible, EOL data missing, unresolved reference).

With --register, the inventory is stored as usage.json in the package <group>--<project>, version latest. There is one record per project, overwritten by each scan: the last published scan describes the project. Decide when to scan with the rules: of the pipeline (tags only, default branch…).

{
"project": "myteam/myservice",
"ref": "1.2.0",
"revision": "a3f8b1c",
"scanned_at": "2026-10-29T10:00:00Z",
"source": "https://gitlab.example.com/myteam/myservice",
"images": [
{
"ref": "registry.example.com/bases/alpine:3.21.3-core1.0.0",
"kind": "base",
"sources": ["Dockerfile:2"],
"status": "update",
"latest_tag": "3.21.4-core1.0.0",
"eol_product": "alpine",
"eol_cycle": "3.21",
"eol_date": "2026-11-01"
},
{
"ref": "docker:26-dind",
"kind": "unmanaged",
"sources": [".gitlab-ci.yml:51"]
}
],
"produces": [
{
"image": "registry.example.com/apps/myservice:1.2.0",
"version": "1.2.0",
"platforms": ["linux/amd64"]
}
],
"custom": { "team": "backend" }
}

--produces images are enriched from their OCI manifest annotations, falling back to the image config labels: org.opencontainers.image.version, org.opencontainers.image.url, imglife.platforms.

scan-images:
stage: scan
image:
name: registry.gitlab.com/imglife-project/imglife:latest
entrypoint: [""]
variables:
IMGLIFE_CONFIG: imglife.yaml # provides registry.* to derive the remote config URL
script:
- |
imglife scan --register \
--produces "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" \
--field team=backend
needs: [build-image]
rules:
- if: $CI_COMMIT_TAG

One job is enough, even for a multi-image project: every image is found and stored in the same record.

Mode Exits 1 when…
default a managed image is WARNING, CRITICAL or EOL
--strict also: an update is available, EOL data is missing, a managed reference is unresolved or unchecked
--warn never

Unmanaged images never fail the pipeline. Configuration and publication errors exit 1.