This reusable checklist shows how to scan Docker images and software dependencies for known vulnerabilities, exposed secrets, and suspicious files before deployment, while preserving enough evidence to investigate failures and exceptions later.
Overview
Container security is not a single scan. A deployable image combines a base operating system, application packages, language dependencies, configuration files, build tools, and sometimes credentials or other sensitive material. Each layer can introduce a different type of risk.
A practical review should therefore cover four areas:
- Provenance: where the base image and application dependencies came from, and whether the build can be reproduced.
- Vulnerabilities: known weaknesses in operating-system packages, language libraries, and application dependencies.
- Malicious or unwanted content: suspicious binaries, unexpected scripts, altered packages, and files that do not belong in the image.
- Secrets and configuration: API keys, private keys, tokens, passwords, debug settings, and excessive permissions.
No scanner proves that an image is safe. Vulnerability databases can miss newly disclosed issues, malware scanners can produce false positives, and a clean image scan does not guarantee that the source repository or runtime environment is trustworthy. Use scanning as a repeatable control alongside code review, dependency management, image signing or provenance checks where appropriate, least privilege, and runtime monitoring.
For a small project, scanning the final image before release may be enough to establish a baseline. For a team or production service, scan source dependencies, build outputs, registry contents, and running workloads at different points in the delivery process.
Checklist by scenario
Before building the image
- Choose a maintained, minimal base image from a source your team can identify and trust. Record the image name, tag, digest, and date selected. A tag can move over time, so use a digest when reproducibility matters.
- Review the Dockerfile. Check every
FROM, downloaded archive, package repository, install script, and shell command. Avoid piping remote content directly into a shell unless the process includes verification and a clear reason. - Lock application dependencies where the ecosystem supports it. Review lockfiles and remove packages that are no longer needed.
- Keep secrets out of build arguments, copied files, image layers, and shell history. Use a suitable secret-management mechanism during builds and at runtime.
- Run a dependency and secret scan against the source tree before creating the image. Tools such as package-manager audit features, SBOM tools, and secret scanners can complement image scanning.
After building a local image
- Record the exact image reference and digest produced by the build.
- Inspect the layer history with
docker history --no-trunc IMAGE_NAME. Look for unexpected downloads, embedded credentials, debugging utilities, or large files that should not ship. - Generate a software bill of materials (SBOM). For example, a Syft-based workflow may use
syft IMAGE_NAME -o spdx-json=sbom.json. Confirm the output format and command options against the installed version. - Scan the image and its SBOM for known vulnerabilities. Trivy and Grype are examples of tools commonly used for this purpose; a representative command is
trivy image IMAGE_NAMEorgrype IMAGE_NAME. - Run a secret scan against the source directory and, where supported, the image filesystem. A secret scan should not replace checking the Dockerfile and build logs.
- Use malware scanning when the image contains downloaded executables, user-uploaded content, or files from an unverified source. Export the image or inspect its filesystem in an isolated environment, and treat detections as an investigation trigger rather than automatically deleting evidence.
In continuous integration
- Build from a clean runner and scan the resulting image, not only the source manifest.
- Generate and retain the SBOM with the build artifact. Link it to the image digest so later reviews identify the exact contents scanned.
- Set a documented failure policy. A team might block critical or high-severity findings in reachable production components, while allowing a reviewed exception for a development-only package. The threshold should reflect exploitability, exposure, available fixes, and business impact rather than severity alone.
- Make results visible in pull requests and release records. Include the scanner, database update time if available, image digest, findings, and decision.
- Prevent bypasses from becoming routine. Require an owner, reason, compensating control, and expiration date for every exception.
For images already in a registry
- Inventory repositories, tags, digests, owners, deployment status, and last-use dates.
- Rescan stored images when vulnerability data changes, even if the image itself has not changed.
- Prioritize images that are internet-facing, privileged, widely deployed, or built from unsupported components.
- Retire unneeded tags and restrict who can push, overwrite, or pull sensitive images.
- Rebuild rather than manually patching a running container. Rebuilding creates a traceable artifact and reduces configuration drift.
What to double-check
- Scan scope: Confirm whether the tool examined operating-system packages, language libraries, application files, image configuration, and secrets. Different scanners cover different layers.
- Database freshness: Note when vulnerability and malware databases were last updated. A scan made with stale data should not be treated like a current assessment.
- Reachability: A vulnerable package may be installed but unused, or it may be directly exposed through an application endpoint. Record this context instead of relying on a severity number alone.
- False positives and disputed findings: Verify the package version, operating-system distribution, affected component, and vendor advisory. Do not suppress a finding solely because it is inconvenient.
- Deleted secrets: Removing a credential from the final filesystem may not remove it from an earlier image layer or build cache. Rotate exposed credentials and review how the image was built.
- Runtime differences: Compare the scanned image with the deployed digest. A registry tag, local image, and running workload may not refer to the same artifact.
- Permissions: Check the user, Linux capabilities, mounted volumes, writable paths, exposed ports, and network access. Vulnerability scanning cannot compensate for an over-privileged container.
Common mistakes
Scanning only the base image. Application dependencies and files added later can introduce the most relevant findings. Scan the complete image and its source dependencies.
Treating a clean result as proof of no malware. Scanners have limits, especially with custom binaries, encrypted payloads, newly created threats, and malicious behavior that appears only at runtime. Use trusted sources, reproducible builds, code review, and runtime controls as additional safeguards.
Using floating tags without recording digests. A later pull may produce different contents. Pin important inputs and preserve the digest used for each release.
Blocking every finding without triage. This can encourage unsafe bypasses. Establish severity and exception rules before the pipeline is under release pressure, then revisit those rules as the environment changes.
Ignoring old registry images. A vulnerable image can remain available after a newer release is deployed. Inventory and rescan stored artifacts, then remove or quarantine those no longer needed.
When to revisit
Revisit this checklist before seasonal planning cycles, before a major release, and whenever the build or deployment workflow changes. Repeat the review when you change the base image, package manager, lockfile, compiler, CI runner, registry, or image-scanning tool.
Set a recurring registry audit so previously scanned images are checked against updated vulnerability and malware data. Reassess immediately after a relevant vulnerability disclosure, a suspected compromise, a secret exposure, or an unexpected change in image contents.
To make the next review efficient, retain the image digest, SBOM, scan output, tool versions, database date when available, exceptions, and remediation decisions. Start each cycle by comparing those records with the current artifact. If a finding is confirmed, rebuild from trusted inputs, rotate exposed credentials, test the replacement image, and verify that the deployed workload uses the new digest.