A Pi-hole rebuild shows why RPM inventory matters on a minimal container base
A Red Hat engineer compares two ways to add packages to a runtime without a package manager and explains why they produce different scanner results.
A minimal container base can remove tools that an application does not need at runtime, but the way a build puts dependencies back determines what a scanner can see. In a November 24 Red Hat Developer walkthrough, Red Hat engineer Matt Micene uses a Pi-hole rebuild to compare two ways to install RPMs on Red Hat Hardened Images’ core-runtime, which does not ship dnf. The write-up describes a work in progress, not a supported Pi-hole distribution or a new vulnerability advisory.
Why copying an install root changes the inventory
The build separates the tools used to assemble Pi-hole from the files needed to run it. In the first approach, the builder installs RPMs into a clean directory with dnf and copies that tree over the runtime. Because the transaction starts without the base image’s RPM database, it resolves dependencies from scratch. It can duplicate packages already present in the base or choose a larger package variant. Copying the tree over the base replaces the visible RPM database while leaving the original files in a lower image layer. Micene notes that tools reading the RPM database can still run, but their inventory may differ substantially from a scan of the original base.
Install against the image that will actually run
In the second approach, the Containerfile mounts the builder image during a RUN step and invokes its dnf with the builder’s library and RPM configuration paths. The transaction installs the extra packages in the final target and updates that target’s RPM database. Micene reports that Grype then matched the manually added dependencies against its published vulnerability feed. That is a result from this build, not a claim that the pattern makes an image vulnerability-free.
What to check in your own build
Compare the final package inventory with the intended base and dependencies rather than assuming a successful build preserved the metadata. Also check whether the application expects tooling from its former base: in this example, Alpine supplied BusyBox symlinks that the replacement package did not create. Micene eventually created the links at build time rather than maintaining changes to individual helper scripts. The walkthrough also describes tracking three update streams in Renovate: upstream application releases, the base image, and RPMs added separately. Those packages can change on a different schedule from the base, so watching only the base tag is not enough for this build.
sources
- Red Hat Developer: Lessons from a real container build using Red Hat Hardened Imagesdevelopers.redhat.com
comments · 0