Docker image security scanning is most useful when it is part of a repeatable remediation workflow, not a one-time report. This guide explains how to select safer images, generate and inspect a Docker image SBOM, triage findings, verify fixes, and design CI gates that reduce deployment risk without blocking every build unnecessarily.
Overview
A container vulnerability scan compares software discovered in an image with vulnerability information from one or more databases. The result can include operating-system packages, language dependencies, application binaries, and sometimes configuration or secret findings. A scan is evidence for a decision; it is not, by itself, a complete risk assessment.
The most reliable workflow starts before the first scan. Choose a maintained base image, keep the Dockerfile reproducible, pin important inputs, and build the image through a controlled pipeline. Then scan the exact immutable image digest that will be promoted. Scanning only a developer workstation build or a tag such as latest can produce results that do not represent production.
For a practical baseline, record these details for every release:
- Image name, tag, and immutable digest.
- Base image name, version, digest, and package manager.
- Scanner name and version, database or advisory data timestamp, and scan command.
- SBOM format and generation method.
- Findings accepted, fixed, deferred, or rejected, with an owner and review date.
Teams may use a local tool such as Trivy or Grype, a commercial workflow such as Docker Scout, or a registry-native scanner. The important control is consistency: the same image should be scanned at predictable points, and the result should remain available for later review.
What to track
Image and base-image inputs
Track whether the image uses a minimal, supported base and whether its packages are installed only when required. A smaller image can reduce the number of packages that need maintenance, but size alone is not a security guarantee. A minimal image may also make troubleshooting or compatibility harder, so select the base according to the application and operational requirements.
Review Dockerfile instructions that add package caches, compilers, test artifacts, credentials, or unnecessary shells. Multi-stage builds can keep build tools out of the runtime image. For additional guidance, see the Dockerfile best practices guide.
SBOM contents and provenance
An SBOM gives the team a package inventory to compare against newly disclosed issues. Generate it for the final image, preserve it with the build record, and identify how it was produced. Common exchange formats include SPDX and CycloneDX, but the exact choice should match the systems that consume the inventory.
Compare the SBOM with the scanner's package list when results seem surprising. Differences can arise from package detection methods, language lockfiles, stripped metadata, or database coverage. Treat the SBOM as a useful inventory, not proof that every component has been detected perfectly.
Finding context
For each finding, capture the vulnerability identifier when available, affected package, installed version, fixed version if known, severity, location, and whether the package is present in the runtime image. Also record exploitability or exposure information used by your organization. A high severity in a development-only package may deserve a different response from a lower-severity issue in a network-facing runtime component.
Tool capabilities
| Tool category | Useful role | Questions to check |
|---|---|---|
| Trivy | Convenient scanning of images, filesystems, repositories, and related artifacts. | Which scanners and output formats are enabled? How are database updates and ignored findings managed? |
| Grype | Focused vulnerability matching for container images and SBOMs. | Can it scan the image or SBOM format used by your build? How will results be retained? |
| Docker Scout | Docker-oriented image analysis and recommendations within a Docker workflow. | Which repository, registry, and policy integrations fit your delivery process? |
| Registry-native scanner | Continuous visibility for images stored in a managed registry. | How quickly are new advisories reflected, and can policies follow an image into deployment? |
These categories are not mutually exclusive. A local scanner can provide fast pull-request feedback while a registry scanner provides ongoing monitoring after publication. Recheck commands, flags, database behavior, and output fields against the selected tool's current documentation before standardizing a pipeline.
Cadence and checkpoints
At build and pull request time
Run a fast scan against the candidate image or its build context before publication. This is the right place to catch newly introduced packages, secrets, and obvious critical findings. Keep the output attached to the build so a developer can see the affected package and proposed remediation rather than receiving only a failed status.
A representative command might look like trivy image --severity HIGH,CRITICAL IMAGE:TAG, or, with another scanner, an equivalent image command that emits JSON or a table. Do not copy a command into production policy without checking the installed version, output semantics, and database configuration. If the pipeline builds by digest, scan that digest.
Before promotion
Perform a fuller scan before an image enters a staging or production registry. Generate or attach the SBOM, verify that the image came from the expected build, and apply the release policy. A useful gate distinguishes between findings in the final runtime layer and findings that exist only in discarded build stages.
After publication
New advisories can affect an unchanged image. Registry or scheduled scans should therefore rescan retained images as vulnerability data changes. Keep a list of deployed digests, not just tags, so a newly identified issue can be mapped to actual workloads.
Monthly or quarterly review
At a recurring review, sample production images and confirm that scans still run, databases update, exceptions have owners, and critical findings have not exceeded their due dates. Review the base-image update process, scanner versions, policy thresholds, and alert volume. A quarterly review is a reasonable starting point; teams with rapid releases or higher exposure may need a shorter interval.
How to interpret changes
Prioritize before upgrading
Start with findings that are present in the deployed runtime, affect reachable functionality, and have a practical fix. Consider severity alongside exposure, exploitability information, data sensitivity, network access, privileges, and whether the vulnerable code path is used. The scanner's severity is an input to prioritization, not a substitute for it.
When a fixed version exists, update the direct dependency, base image, or package constraint that controls it. Rebuild from a clean context rather than modifying a running container. If the issue comes from an indirect dependency, update the parent package or regenerate the lockfile using the project's normal dependency process.
Review apparent false positives carefully
A finding may be inaccurate because the package was removed, the scanner identified a file in an unused path, the platform backported a fix without changing its visible version, or advisory metadata does not match the distribution's package naming. Validate the package inside the final image, consult the distribution or upstream advisory, and document the reasoning. Do not suppress a finding merely because the application is not believed to call the affected feature.
Use narrow, time-limited exceptions. Record the image digest, finding, rationale, compensating controls, owner, approval, and expiration or review date. A global ignore rule can hide the same issue in unrelated images and make later audits difficult.
Verify remediation
After changing the Dockerfile or dependency, rebuild without relying on a stale layer where appropriate, generate a fresh SBOM, and rescan the resulting digest. Confirm that the vulnerable package is gone or is at the expected fixed version. Then run application tests, image startup checks, and deployment validation. A security fix that breaks the service is not complete until reliability has been restored.
Image signing and provenance can strengthen this chain by allowing a registry or deployment system to verify who built an image and whether it came from an approved workflow. Select a signing and verification approach that your runtime actually enforces, and protect signing credentials separately from ordinary build credentials.
When to revisit
Return to this workflow whenever an image is rebuilt, its base image changes, a dependency lockfile changes, or a new release is promoted. Also revisit it when an advisory affects a package in your image, a scanner changes its database or matching behavior, or a registry and deployment policy changes.
For a standing monthly or quarterly checkpoint, use this short review:
- List deployed image digests and identify images that are no longer supported or no longer needed.
- Rescan retained and production images with current vulnerability data.
- Compare new findings with the previous report and prioritize runtime exposure first.
- Open remediation work with owners and due dates; expire or reapprove exceptions deliberately.
- Update base images and dependencies, rebuild, regenerate SBOMs, and verify the final digest.
- Test that CI gates, signing checks, notifications, and registry policies still behave as intended.
Keep this checklist beside the pipeline configuration and record the date, scanner version, database state, and policy revision. That history makes changes explainable and prevents teams from treating an old clean scan as permanent evidence of safety. For broader delivery controls, pair image scanning with a defined SLO and error budget process, and use the Kubernetes upgrade checklist when image remediation is part of a cluster release.