tezvyn:

Docker Image Scanning: A Background Check for Your Code

AI-drafted, machine-checkedSource: docs.docker.comadvanced

Docker image scanning is a background check for your software dependencies, checking packages against known vulnerability lists (CVEs). It's used in CI/CD to block vulnerable builds and in registries for continuous monitoring.

WHY IT EXISTS: Docker images are composed of layers, often starting with a public base image. These layers can contain outdated packages with known security holes (CVEs), creating a significant attack surface before your own code even runs. Without scanning, you are blindly trusting every piece of software in your stack.

THE MENTAL MODEL: Docker image scanning is a security background check for your container's contents. You give a scanner an image, and it produces a report listing all the software "inhabitants" (OS packages, language libraries) and flags any with a known criminal record (a published CVE). It tells you what is in your image and if it can be trusted.

HOW IT WORKS: The process involves three main steps. First, the scanner inventories all software packages within the image layers, identifying components like libc, openssl, or python libraries and their specific versions. Second, it compares this inventory against one or more vulnerability databases. Third, it generates a report detailing any matches, usually categorized by severity (e.g., Critical, High, Low), and provides a link to the specific CVE for remediation details.

WHEN TO USE IT: Implement scanning at multiple points. First, during development, to empower developers to fix issues early. Second, in your CI/CD pipeline, to act as a gate that can automatically fail builds containing critical vulnerabilities. Third, within your container registry, to continuously re-scan images, as new vulnerabilities are disclosed daily for existing software.

WHEN NOT TO USE IT: You should almost always use it. The only exception might be for short-lived, entirely isolated, non-networked containers in a development environment where the risk is explicitly accepted. For any production system, scanning is mandatory. The cost of a breach far outweighs the cost of adding a scan step to your build.

ONE CANONICAL EXAMPLE: A CI pipeline builds a web app using the node:18-alpine base image. A scanning tool like Trivy or Docker Scout runs after the build. It detects that the version of the zlib library in the Alpine base has a newly discovered remote code execution vulnerability. The scanner reports this as a "Critical" finding and, based on policy, the CI pipeline fails, preventing the vulnerable image from being pushed to the registry.

Read the original → docs.docker.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.