← Back to blog
Published November 4, 20266 min read

Container Image Vulnerabilities: Fix the Image, Not the Running Container

Container SecurityContainersVulnerability ManagementDevSecOps

Your container scanner just returned hundreds of findings for a single image. Many of them don't come from the code your team wrote. They arrived with the base image, the operating system packages and the build tools that nobody removed. The instinct is to open a ticket per CVE and ask someone to "patch the container". That instinct is wrong, and it's why container vulnerability backlogs never seem to shrink.

This guide explains where container image vulnerabilities come from, why you fix them in the image and not in the running container, and how to decide which ones deserve attention first.

Why container images carry so many vulnerabilities

A container image is a stack of layers. At the bottom sits a base image, often a full Linux distribution with a shell, a package manager and hundreds of libraries. On top come language runtimes, application dependencies and, finally, your code. Every layer brings its own CVEs, and a scanner reports all of them at once.

The numbers show how common this is. In its 2023 Cloud-Native Security and Usage Report, Sysdig found that 87% of container images running in production had at least one high or critical vulnerability. The same report adds the nuance that matters: only about 15% of the critical and high vulnerabilities that had a fix available were in packages actually loaded at runtime. The rest sat in packages that were present in the image but never used.

That gap is the whole story. An image full of unused packages produces long reports, but much of the risk is concentrated in a smaller set of components that actually run.

You don't patch a container. You replace it.

On a traditional server, you patch in place: log in, update the package, restart the service. Containers are designed differently. NIST's Application Container Security Guide (SP 800-190) describes containers as meant to be deployed but not changed. When a running container needs an update, it is destroyed and replaced with a new one built from an updated image. As a result, vulnerability management, including patches and configuration, happens when the image is built.

This has three practical consequences:

  • Patching a running container is wasted work. The next deployment, scaling event or restart brings back the original image with the original vulnerabilities.
  • The fix lives in the build. You change the Dockerfile, the base image tag or a dependency version, rebuild and redeploy.
  • Ownership moves left. The person who can fix the finding is usually the team that owns the Dockerfile and the pipeline, not the operations team that runs the cluster.

Where the fix actually happens

Start with a smaller base image

Docker's own build best practices recommend choosing a trusted base image and keeping it small, because a smaller base shrinks the image and minimizes the number of vulnerabilities that come from dependencies. Options include slim variants of official images and "distroless" images, which, according to the Google project that maintains them, contain only your application and its runtime dependencies: no package manager, no shell and none of the other programs you'd expect in a standard Linux distribution. The project notes that this improves the signal-to-noise ratio of CVE scanners.

Fewer packages means fewer findings, but also fewer tools for an attacker who lands inside the container.

Use multi-stage builds

Compilers, build tools and test frameworks are needed to build your application, not to run it. Multi-stage builds separate the build environment from the final image, so only the artifacts the application needs reach production. Everything left behind in the build stage stops showing up in your production scans.

Rebuild on a schedule, not only when the code changes

An image is a snapshot. If your application code doesn't change for three months, the image doesn't either, while new CVEs keep being published against the packages inside it. Docker's guidance is to rebuild images regularly with updated dependencies, using the option that pulls a fresh base image so you don't reuse an old one from the cache. A weekly or nightly rebuild picks up base image fixes without waiting for a feature release.

Scan in the pipeline and in the registry

Scan images in CI before they're pushed, so a new critical finding can block a release the same way a failing test does. Then keep scanning the images already in your registry and in your clusters, because a clean scan today says nothing about the CVEs published next week. For more on this, see our guide to Kubernetes security posture.

How to prioritize container findings

Even with a lean image, you'll have more findings than time. Use the same logic as any risk-based program:

  1. Is the vulnerable package loaded at runtime? A vulnerable library that is present but never executed is much less urgent than one in the request path. This is the container equivalent of reachability analysis in SCA.
  2. Is it being exploited? A CVE in CISA's KEV catalog or with a high EPSS score jumps the queue, whatever its CVSS.
  3. Is the workload exposed? An internet-facing API container matters more than an internal batch job.
  4. Is there a fix? If the base image publisher hasn't released a fix yet, record the exception with an owner and a review date instead of leaving it open forever.
  5. One fix, many findings. Updating a single base image often closes hundreds of findings across dozens of services. Group findings by the action that fixes them, not by CVE.

An SBOM for each image makes all of this faster: when a new CVE appears, you can answer "where do we run this?" in minutes. Our SBOM guide explains how to generate and use one.

Common mistakes

  • Using "latest" and assuming it's current. A floating tag can resolve to a different version over time, and a cached copy can be months old. Know which base image version each service actually runs.
  • Treating every image finding as an application bug. Many findings come from the base layers. Route them to whoever owns the base image, ideally a platform team that maintains approved images for everyone.
  • Fixing the container, not the source. A hotfix applied with a shell inside a running container disappears on the next restart.
  • Forgetting the copies. The same vulnerable library can live in the base image and again inside an application bundle. See bundled dependencies and hidden copies.

Frequently asked questions

Should we block every build with a critical finding? Start by blocking criticals that are exploited (KEV) or have a fix available, and report the rest. A gate that blocks everything gets bypassed.

Is distroless always the right choice? Not always. Without a shell, debugging is harder, and some applications need system libraries. A slim official image is a good middle ground.

How often should we rebuild? At least whenever the base image publishes a security update, and on a fixed schedule even if the code hasn't changed.

How priorIQ.ai helps

CodeIQ scans container images and infrastructure as code alongside first-party code and dependencies, with SCA reachability and SBOM generation in CycloneDX and SPDX, a pipeline gate and verified AI fixes opened as pull requests. Its findings join the same risk model as endpoints and cloud, and PriorIQ Core reconciles them, prioritizes with exploitation and exposure context and groups them into remediation actions, so updating one base image shows up as one action, not hundreds of tickets. The ScannerIQ Kubernetes agent adds RBAC, workload and NetworkPolicy posture from inside the cluster. Request a demo.