Supply Chain Security Index
Home / Guides / How to Migrate to Hardened Base Images Without Breaking Builds

How to Migrate to Hardened Base Images Without Breaking Builds

Updated Written by Shir A.Reviewed by Leonardo C.8 min readMethodology

Migrating to hardened base images is mostly a Dockerfile change, but the effort depends on one decision: whether the new images are drop-in replacements for what you run today or a different distribution.

Step 1: Inventory your base images

List every distinct base image in your registries and Dockerfiles, with its tag and the number of services that use it. Most fleets are dominated by a handful: a few Python, Node.js and Java runtimes, nginx, and a couple of databases or brokers. Those are the first targets, because each swap removes CVEs from many services at once. Wiz, Snyk and similar tools can map vulnerabilities to the base layer to help prioritize.

Step 2: Decide drop-in or re-base

Drop-in replacementRe-base onto a new distribution
ExampleEcho, RapidFort, Docker Hardened ImagesChainguard (Wolfi), WizOS (Alpine-compatible), CleanStart
Dockerfile changeThe FROM lineFROM line, package manager commands, sometimes the user and paths
Typical blockerRareShell-less images, apk vs apt, glibc vs musl
Pilot timeHoursDays per image family

Step 3: Pilot on one service

Pick a service with good test coverage that uses one of your most common bases. Change the FROM line, rebuild, run the tests and scan the result. With a drop-in provider such as Echo, this is the whole migration for most services. Record the CVE count before and after, which becomes the business case for the rest of the fleet.

Step 4: Handle the build stage

Minimal runtime images often have no shell or package manager. Use multi-stage builds: compile and install dependencies in a builder image that has the tools, then copy the result into the minimal runtime image. Most hardened image vendors publish a development variant for the builder stage.

Step 5: Do not forget the libraries

A clean base image does not stay clean once npm install or pip install runs on top of it. Point your package managers at a hardened library source, such as Echo Libraries or Chainguard Libraries, or mirror it into Artifactory or Nexus. See the rankings for hardened npm packages and hardened Python libraries.

Step 6: Roll out and lock in

Common mistakes

Related guides