Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Resources to explore

Check out popular resources, tools, and information from Red Hat. We'll recommend more as you browse.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

Chasing CVEs: Lessons from a real container build using Red Hat Hardened Images

Real apps, minimal base images: Lessons from the field

November 24, 2026
Matt Micene
Related topics:
Containers
Related products:
RHEL UBI

    After we launched Red Hat Hardened Images in May, I decided to migrate a containerized application I use at home to one of our images. I'd spent some time helping build the initial examples, and seen some issues with the distroless approach for a sample Python application, but I still needed to go deeper.

    Knowing that minimization and distroless approaches shift how we need to build containerized applications, I decided to target the runtime environment with the smallest starting footprint. Our core-runtime is designed with dynamically linked applications in mind. No extra development tools, just libraries and a few other packages.

    The goal: Take a containerized application I use somewhat regularly and rebuild it on a Red Hat Hardened Image. I have a functioning comparison point to know what done looks like.

    The app: Pi-hole is a DNS sink I use to block access to sites on my home network. It also isn't a simple "run Ruby app on Ruby image" conversion, either. It's a mix of shell, compiled C, and JavaScript. There's some helper scripts in the project to make the containerized environment provide similar functionality as the full OS the Pi-hole expects to see. I can't simply run curl | bash on the installer and expect anything to work.

    The method: Examine the upstream project container for a basic design but target, at minimum, a final image based on core-runtime with Bash added. I don't want to just change all the commands in the official Containerfile from Alpine, but actually examine what that project did, and why.

    If I'm going to rebuild a perfectly working container image, I may as well make it a challenge. It really is still a work in progress, but I have a fully rebuilt image that I'm happy with. Here's what I learned along the way.

    Multi-stage builds are important

    The application is really 3 separate projects that get installed together. The compiled FTL DNS server is installed from a Github release, but the main Pi-hole application and the dashboard are cloned repos that get "installed". I don't need all the Git history or the supporting tooling, just the application files. The project installer also helpfully documents all the required packages, so I can review those against available RPMs.

    Separating the build time artifacts and tools and run time tools to get that minimized footprint really benefits from multi-stage container builds. I keep all of the tracking, and install for the project in the builder stage, then just add the final files and the dependencies (like Bash) to the final stage.

    RUN with mount

    Even with the list published by the project, getting the final image right still took a little experimentation. Because these dependencies required RPMs installed in the final image, there are 2 basic options. There's no dnf in the core-runtime, so that's not an option.

    The builder stage uses the core-runtime:builder image, which does include dnf for package installs. The first option is to install the needed RPMs to a specific location in the builder stage, then copy that location in the final stage into the target image.

    That's a pretty common pattern and works fine. Passing installroot to dnf means you have a nice clean spot to land your packages for copying. However, because the actual dnf transaction happens in the build stage, the rpmdb in the final image gets overwritten by these new packages. This works, but not in the way you might expect.

    With a "clean" install root, dnf treats this as a completely new transaction and resolves all dependencies for the package list. Because there is no pre-existing rpmdb, there are duplicated packages in the new root like glibc or filesystem in the transaction. There may be packages with higher capabilities installed, like installing coreutils where coreutils-single in the base image would have sufficed. When the COPY happens, this essentially lays down a whole new root filesystem over the existing image, leaving the original files on a lower layer. CVE scanners and SBOM generators that operate on the rpmdb still work, but what they see may be very different from a scan of the core-runtime base.

    This installroot pattern is more suited to scratch builds than using a minimal base image.

    The other option still uses dnf in the core-runtime:builder image to install the RPMs, just in a slightly different way than you may have seen before. It was certainly new to me.

    The RUN directive in a Containerfile has the --mount option to attach a filesystem to this particular operation. You may have seen this as a way to pass a secret into a container build from a command-line argument as --mount type=secret which shows up in the image under /run/secrets. Here, we can use this to mount the core-runtime:builder image as a file system at a specific location, then use tools relative to that path.

    RUN --mount=type=bind,from=registry.access.redhat.com/hi/core-runtime:latest-builder,target=/builder \
        LD_LIBRARY_PATH=/builder/lib64:/builder/usr/lib64 \
        RPM_CONFIGDIR=/builder/usr/lib/rpm \
        /builder/usr/bin/dnf install -y

    The whole image gets mounted at /builder and we run dnf right from there. As it does run from that mounted path, we also need to tell dnf where to look for the correct libraries and configuration files. Now, you can see there's more setup needed than just doing this in the build stage. But the result is the packages get installed, and the rpmdb is updated in the final target. When I use grype to look for CVEs, any of the Pi-hole dependencies I added manually get matched to the published feed correctly.

    Conversion changes

    I mentioned that the project publishes a list of dependencies for its installer, but that installer is also designed to work for a number of different operating systems. The container image is built on Alpine. That project has some helper scripts that get used to do things during build that would have been done by the installer.

    The goal was to carry as few upstream project modifications as possible, but those helper scripts were fair game. The minimization goal means only add the absolute necessities, and that means looking at things like how updates for block lists are scheduled.

    One packaging difference came up that I addressed a few different ways. The Busybox package shipped in Alpine creates all of the symlinks at package build, ours doesn't. These symlinks let the appropriate busybox function be called from the standard Linux utility location. At first I was hesitant to create the symlinks, and changed things to explicit calls. It made things clear but also meant maintaining busybox sed edits in a few files.

    After a few rounds of builds and troubleshooting and an FTL update that showed some previously silent failures, I changed tack and created all the links at build time for the final stage. This was a simple single line in the Containerfile, and cleaned up a lot of minor downstream changes.

    Busybox sidecar

    The image was using Alpine's busybox package, which we have available to us as well. There are some differences in how they are packaged. The coreutils packages are also different in each distro. While looking at this conversion process, I was also testing out the published AI skills. Figuring out what was provided and how proved to be a little tedious, even with the help of an agent. And the choices the agent made weren't always the best.

    So I made myself a little "sidecar" container, built from the core-runtime:builder with Busybox installed. That's all, nothing complicated. However, this meant I had an easy way to check for available commands with busybox --list, or the contents of a package with rpm -ql, or even simulate a full install with dnf --assumeno install and see all the packages that would get pulled in.

    $ podman run --rm \
    -it localhost/hum-cap:latest dnf install --assumeno  --no-docs vim-minimal
    Updating and loading repositories:
    Repositories loaded.
    Package                                 Arch    Version                                  Repository                              Size
    Installing:
     vim-minimal                            x86_64  2:9.2.843-1.hum1                         public-hummingbird-x86_64-rpms       1.8 MiB
    Installing dependencies:
     vim-data                               noarch  2:9.2.843-1.hum1                         public-hummingbird-x86_64-rpms      10.2 KiB
    Transaction Summary:
     Installing:         2 packages
    Total size of inbound packages is 924 KiB. Need to download 924 KiB.
    After this operation, 2 MiB extra will be used (install 2 MiB, remove 0 B).
    Operation aborted by the user.

    Integrating updates

    With a working image, the next thing that I needed to work out was how to keep everything up to date. I had to track the project for updates and the images I was using. Red Hat Hardened Images are rebuilt whenever a change is detected in the images packages. I was going to have to automate all of this to make sure everything stayed together.

    Enter renovatebot

    Renovate is a pretty capable tool for keeping track of dependencies of various types. For Github, it can even create pull requests with the changes for review. Quite literally up first was the project releases. Every time there's a new release, I want to make sure to pull it into the build system. Github releases are an existing datasource, so I just needed to alter the Containerfile to give renovate something to track and modify. The versions became args with a helper comment for renovate to hook on to. Whenever Pi-hole pushes out new versions of anything, I get a candidate PR with the change to pull in that new version.

    With the build stage done, the target stage was up next. First was the core-runtime image itself. No use having a rapidly rebuilt image if you aren't tracking those changes. Again, container images are already something renovate knows all about, I just needed to make sure it had the redhat version hints in the config and it was tracking our base.

    In many cases, that may be all you need to monitor for your final image. But I had added RPMs during the final stage, so I wanted to make sure to track those too. Because Busybox isn't in the core-runtime image, it could be updated on a different cycle. Tracking those individually means PRs are opened for any updates that affect the final running image. The RPM datasource made it just as easy to add as the Github releases.

    Testing testing

    Finally, all of these automated possible changes and iterations meant adding testing to the builds. None of this is worth the time spent if the DNS sink doesn't actually sink the request. That meant testing whether the Pi-hole image did its job, but also that the unbound DNS server I was using from Red Hat Hardened Images did its job, and that they worked together as a pod like they would in the final deployment.

    The result

    That might sound like a whole lot of work, so what did I gain at the end? A regularly updated application, published as a pipeline, that's up to date and easy to understand. I've only had to pay attention to 1 update where an upstream project made a functional change in response to a CVE.

    To do this for your app, head to images.redhat.com and find your own starting point.

    Related Posts

    • Build bootable image mode for Red Hat Enterprise Linux with image builder

    • Security is Getting Harder: Here's Why Image Mode for RHEL Helps

    • Bootable containers: Reduce friction with Red Hat Enterprise Linux image mode

    • Getting started with containers using Podman

    • Harden local container base images in Podman Desktop

    • Red Hat UBI vs. Red Hat Hardened Images: How to choose

    Recent Posts

    • JBoss EAP 8.2 Beta: Java SE 25 and automated provisioning

    • Chasing CVEs: Lessons from a real container build using Red Hat Hardened Images

    • Draining 10K VMs with Dirty Memory at 100-Node Scale

    • Configure Red Hat OpenShift Lightspeed autonomous agents

    • High Scale Performance Testing of OpenShift Virtualization : An Introduction

    What’s up next?

    Learning Path RHEL platform card

    Build a Python Flask application with Red Hat Hardened Images

    Develop a Flask application using Red Hat hardened images and Red Hat build...
    Red Hat Developers logo

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    Red Hat Developer

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility
    Ask AI