Safeguard
Security Guides•

Rebuild, patch or replace: what to do with each container finding

A decision guide for container scan findings: when to rebuild on a fresh base, change your own layer, swap the base image or record an exception.

Safeguard Security Team
4 min read

Match the action to where the finding lives. Base layer finding with a fix: rebuild on a fresh base. Your own layer: change the Dockerfile or dependency file. No fix and no use for the package: remove it or switch base. No fix and needed: record a time limited exception. Never patch a running container.

Why the layer decides the action

Each image layer is a set of filesystem changes and, once created, is immutable, as the Docker documentation puts it. You cannot edit a finding out of an old layer. You build a new image with different layers. So the useful question is which layer brought the package in, because that tells you which input to change. See what a container image layer is.

The decision table

Finding locationFix available?ActionOwner
OS package in base layersYesRebuild with a fresh pull of the base tagPlatform or app team
OS package you installed in a Dockerfile stepYesRebuild; check the install step is not cachedApp team
Language package from your lockfileYesUpdate the lockfile, rebuildApp team
Runtime or interpreter binaryYesMove to a patched image tagApp team
Package you do not needAnyRemove the install step or use a smaller baseApp team
Any packageNoSee no fix availableSecurity with app team
Fix just in a newer OS releaseNewer release alonePlan a base image move, or record an exceptionPlatform

Rebuild

Docker's build guidance page recommends rebuilding images regularly because an image is a snapshot, and using the pull flag so the build fetches a newer base instead of reusing a cached one. The no cache flag forces every step to run again, and the page says the two serve different purposes and can be combined.

docker build --pull --no-cache -t myapp:2026-10-19 .

Use the no cache flag when a cached install step may be holding old packages, not on every build, since it is slower.

Patch

Patching in place, such as running a package upgrade inside a live container, changes just that container's writable layer. It disappears on restart and leaves the image unchanged. Patching inside the Dockerfile at build time is legitimate, and the trade-offs are in apt upgrade or rebuild.

Replace

Replace the base when a family of findings keeps returning because the base is large, old or reaches its support end. A smaller base reduces packages, and fewer packages means fewer rows. Moving needs testing, since a different C library or shell can change behavior.

Accept with an expiry

If nothing can be fixed now, write the exception with an owner, a reason, a review date and the compensating control. Machine readable status helps downstream readers; see suppress with expiry and VEX.

Order of work

  1. Fix findings in shared base layers first, since one change helps every service. See roll out a patched base image.
  2. Then your lockfile findings.
  3. Then exceptions and removals.

Where Safeguard fits

Safeguard's reachability analysis and policies help rank findings so the first rebuild covers what matters. Autonomous remediation with fix PRs is available but off by default, with every category on Manual until you change it. Free scan: gold.safeguard.sh/scan.

Try it yourself

Click through it at your own pace, or open it full screen. Look for which findings have a fix ready.

Quick check

Is running apt upgrade in a live container a fix?

No. It changes one running container, not the image, and the change is lost when the container is replaced.

When is replacing the base worth the effort?

When the same classes of finding keep returning, or the base is at or near its support end.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.