Skip to content

Guardrails / docker

Dockerfile lint findings are clean ​

docker/lint-clean@v1

Every finding the Dockerfile linter reported is below the severity your team gates on.

Iddocker/lint-clean
Versionv1
Categorydocker
Default severitywarning
Interpreterpython3
Timeout30 seconds
Violations tolerated0
Collectsdocker

Collectors ​

This guardrail doesn't gather anything itself. It relies on the collectors below, which the CLI runs once per build before any check, and reads what they found from GUARDRAIL_FACTS. If a collector collects nothing, this guardrail is skipped, not failed.

CollectorGathersInputs it is given
dockerEvery Dockerfile in the tree, parsed without a tool: the stages it builds, the image each one starts from and how that image is pinned, the user the image ends as, the ports it exposes, the paths it copies in and the names of the build arguments and environment variables it declares, plus the findings of a hadolint report when the build already left one behind.none

The inputs above are this guardrail's own inputs, passed straight through to the collector. Setting one in buildnote.json changes what is collected, and two guardrails configured the same way share a single collection.

Configuration ​

json
{
  "guardrails": {
      "failOn": "error",
      "checks": [
          {
              "use": "docker/lint-clean@v1",
              "severity": "warning",
              "with": {
                  "severity": "high",
                  "ignore": ""
              },
              "exemptions": []
          }
      ]
  }
}

Inputs ​

InputDescriptionDefaultEnvironment variable
severityLowest severity that counts as a violation, on the scale the collector normalises every report to. Findings below it are logged, not reported. One of critical, high, medium, low, info.highGUARDRAIL_INPUT_SEVERITY
ignoreComma separated rule ids that are never a violation, such as DL3008,DL3059.``GUARDRAIL_INPUT_IGNORE

How to fix ​

Fix the findings listed in the violations, or deliberately disable a rule in .hadolint.yaml where it doesn't apply:

yaml
ignored:
  - DL3008

Run the linter in your build before this guardrail, so there is a report to read:

bash
hadolint --format sarif Dockerfile > hadolint.sarif

The guardrail reads the report and never reruns the linter, so it judges the same findings your build acted on.

More in docker ​

  • docker/base-pinned. Every image a Dockerfile builds from is pinned to a digest, so rebuilding the same commit starts from the same bytes.
  • docker/healthcheck. Every Dockerfile declares a HEALTHCHECK, so the orchestrator can tell a container that is running from one that is actually working.
  • docker/no-build-secrets. No ARG or ENV declared in a Dockerfile has a name that looks like a credential.
  • docker/nonroot-user. Every Dockerfile ends with a USER that is not root, so the container runs its process without privileges.

All 5 docker guardrails

Buildnote Limited
Registered in England and Wales, Reg: 16140412