<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: iamenr0s</title>
    <description>The latest articles on DEV Community by iamenr0s (@iamenr0s).</description>
    <link>https://dev.to/iamenr0s</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3843832%2Ff2286c2d-a3dc-4b1a-8ac0-12d69fa00d25.png</url>
      <title>DEV Community: iamenr0s</title>
      <link>https://dev.to/iamenr0s</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iamenr0s"/>
    <language>en</language>
    <item>
      <title>Why I Built an Open-Source Hardened Container Image Platform</title>
      <dc:creator>iamenr0s</dc:creator>
      <pubDate>Thu, 03 Dec 2026 09:53:45 +0000</pubDate>
      <link>https://dev.to/iamenr0s/why-i-built-an-open-source-hardened-container-image-platform-1gig</link>
      <guid>https://dev.to/iamenr0s/why-i-built-an-open-source-hardened-container-image-platform-1gig</guid>
      <description>&lt;p&gt;I have lost count of how many times I have opened a container vulnerability report and saw that a large portion of the findings had little to do with the application. They were taken from the base image.&lt;/p&gt;

&lt;p&gt;If you work with containers, you know the drill. You update your application dependencies, fix the findings you can control, rebuild the image, and scan again. But you are still stuck with operating system packages that your application may not even need.&lt;/p&gt;

&lt;p&gt;I started wondering somewhere along the way about how we even build container images in the first place.&lt;/p&gt;

&lt;p&gt;Here is a standard &lt;code&gt;Dockerfile&lt;/code&gt; instruction:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt; ubuntu:24.04
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is nothing wrong with that line. Ubuntu is a reasonable choice for many workloads. But how often do we look at all that it brings to our application? We are careful about the libraries we use in our code but not about base images. That got me worked up.&lt;/p&gt;

&lt;p&gt;I wanted more control over the filesystem, installed packages, and their maintenance after the image was published. So rather than continue to harden existing images, I decided to try building my own.&lt;/p&gt;

&lt;p&gt;The result is &lt;a href="https://github.com/iamenr0s/docker-hardened-images" rel="noopener noreferrer"&gt;Docker Hardened Images&lt;/a&gt;, an open-source project that has evolved into something much more involved than a collection of Dockerfiles.&lt;/p&gt;

&lt;h2&gt;
  
  
  What if we began again from scratch?
&lt;/h2&gt;

&lt;p&gt;The final Dockerfiles used in the project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt; scratch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I like starting off with an empty filesystem. &lt;code&gt;FROM scratch&lt;/code&gt; alone does not make an image secure; you can easily build an insecure image from scratch. Nothing is inherited, so each piece in the image can be a conscious decision. It gives you control over how the image is assembled.&lt;/p&gt;

&lt;p&gt;I did not want to create another Linux distribution that would have its own problems of package maintenance and compatibility. Instead, I use the existing distribution ecosystem. On Debian and Ubuntu, &lt;code&gt;debootstrap&lt;/code&gt; creates the root file system. On RPM-based distributions I use dnf's install-root facility. The filesystem is built and hardened in a separate build environment and copied into the final image so that the tools used to build it do not have to ship with it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxv8mms4icjqka5yfvuub.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxv8mms4icjqka5yfvuub.png" alt="Figure 1: Root filesystem construction architecture" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The project would have been much easier if we only supported Debian. But not all organizations use Debian, and applications require different operating systems.&lt;/p&gt;

&lt;p&gt;The project now supports 19 different distributions on two processor architectures, amd64 and arm64. They include Debian, Ubuntu, Fedora, AlmaLinux, Rocky Linux, CentOS Stream, Oracle Linux, and Amazon Linux.&lt;/p&gt;

&lt;p&gt;These distributions differ more significantly than you might expect. Package naming is different. Dependency resolution is different. Repositories behave differently. Security updates are different. You cannot write a hardening script for Debian and run it against an RPM-based filesystem and expect the same kind of thing. The logic is mostly common, but there are places where enforcing a single implementation would make things more complex than they need to be.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Much Can You Really Lose?
&lt;/h2&gt;

&lt;p&gt;This is the part of container hardening that I find the most intriguing.&lt;/p&gt;

&lt;p&gt;There is a temptation to strip out anything that does not seem essential, like shells, package managers, and networking utilities. The trouble is that what is ‘essential’ depends entirely on the particular applications you are running. A developer of an image will have different needs than a developer whose only purpose is to run a compiled app.&lt;/p&gt;

&lt;p&gt;I came up with two variants: the full and the micro.&lt;/p&gt;

&lt;p&gt;The full image includes package and shell management features. The full image is still hardened, but it can be stretched like any traditional Linux base image.&lt;/p&gt;

&lt;p&gt;The micro image is more restrictive. It has no shell. No package manager. The user is a default non-root user, with uid and gid 65532.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7uisu17q733ng53my151.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7uisu17q733ng53my151.png" alt="Figure 2: Full versus micro image comparison" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Full&lt;/th&gt;
&lt;th&gt;Micro&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Shell&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Package manager&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Package inventory&lt;/td&gt;
&lt;td&gt;Preserved&lt;/td&gt;
&lt;td&gt;Preserved&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Default user&lt;/td&gt;
&lt;td&gt;Root&lt;/td&gt;
&lt;td&gt;Non-root&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Setuid and setgid permissions&lt;/td&gt;
&lt;td&gt;Stripped&lt;/td&gt;
&lt;td&gt;Stripped&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This split is beneficial for multi-phase building. You build the application and install what you need during a build stage. This stage prepares the dependencies of the application. Then you grab the files you need and copy them into the more restrictive runtime image.&lt;/p&gt;

&lt;p&gt;Not all applications will be able to take advantage of a micro image. Removing the shell will break your application if it starts shell scripts or any software that expects certain system utilities. I prefer two reasonable choices to stuffing all the workloads into the tiniest possible picture.&lt;/p&gt;

&lt;p&gt;One more row to explain in the table. Both variants retain the package inventory metadata. A package manager might not be useful in a production runtime, but the inventory it leaves behind is very useful for vulnerability scanners. Removing it makes it more challenging to identify installed software. The vulnerable component is still there; your vulnerability report might look better.&lt;/p&gt;

&lt;p&gt;I would rather not keep images that look secure just because they are difficult to scan.&lt;/p&gt;

&lt;p&gt;This choice also explains why some full and micro images have the same number of vulnerabilities despite having different run-time capabilities. So, if you think that a smaller image will yield fewer findings, it may seem counterproductive. But limiting what an image can do is not the same as removing vulnerable software.&lt;/p&gt;

&lt;p&gt;The industry overemphasizes raw CVE counts, and I will get back to that in the next article. &lt;/p&gt;

&lt;h2&gt;
  
  
  The less glamorous part: keeping everything updated
&lt;/h2&gt;

&lt;p&gt;Creating an image is just the initial step. The container image can sit in a registry, unchanged, and be affected by a newly disclosed vulnerability overnight. The image itself has not changed, but our understanding of its contents has evolved.&lt;/p&gt;

&lt;p&gt;That is where the project becomes a platform engineering exercise. GitHub Actions builds, secures, publishes, and refreshes images on a schedule. Grype and Trivy are vulnerability assessments, and structural tests are verifying that a rebuild has not lost any of the intended hardening. I want the validation to catch things like a micro image getting an unexpected shell put back into it as part of a package update, for example.&lt;/p&gt;

&lt;p&gt;The project reconstructs images daily but also scans published images for vulnerabilities every 6 hours. Other workflows are intended to trigger remediation in case of certain failures.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fit2lp6cb4wq1bkz2u0ul.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fit2lp6cb4wq1bkz2u0ul.png" alt="Figure 3: Continuous security maintenance lifecycle" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Getting all of this to work consistently on AMD64 and ARM64 was complicated. We have seen one case where Ubuntu ARM64 builds were failing during &lt;code&gt;ldconfig&lt;/code&gt; when running under QEMU emulation, and that build path is now running on native ARM runners. Just because you have added an architecture to a build matrix does not mean you have solved multi-architecture support.&lt;/p&gt;

&lt;p&gt;Reproducibility is harder still. Debian has timestamped repository snapshots, so at least you can control what version of a package you have to a certain point. Live repositories have other issues. The Debian 12 micro experiment documented so far has yielded reproducible package inventories but not bit-for-bit identical images, so there is still work to do.&lt;/p&gt;

&lt;p&gt;I have also added Cosign keyless signing, SBOM generation, and build provenance. I will not go into the implementation, but the logic is simple: if someone is using the image I publish, they should be able to verify where it came from and what software it contains, without having to just trust my description of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Are the images actually any better?
&lt;/h2&gt;

&lt;p&gt;I wanted to get this one correct. A README with hardening measures and a few security badges wouldn’t tell a prospective user how the images compare with what they already use, so I built a separate benchmarking framework.&lt;/p&gt;

&lt;p&gt;It compares the official distribution images with the hardened variants under the same measurement conditions. It logs image digests, scanner versions, and vulnerability database information.&lt;/p&gt;

&lt;p&gt;On December 2, 2026, the benchmark included four distributions on AMD64 and ARM64 with 30 image and architecture combinations measured successfully.&lt;/p&gt;

&lt;p&gt;Here are some compressed image sizes for AMD64:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Distribution&lt;/th&gt;
&lt;th&gt;Official standard&lt;/th&gt;
&lt;th&gt;Hardened micro&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Debian 12&lt;/td&gt;
&lt;td&gt;48.5 MB&lt;/td&gt;
&lt;td&gt;28.8 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ubuntu 24.04&lt;/td&gt;
&lt;td&gt;29.8 MB&lt;/td&gt;
&lt;td&gt;26.6 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fedora 44&lt;/td&gt;
&lt;td&gt;69.8 MB&lt;/td&gt;
&lt;td&gt;36.9 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AlmaLinux 9&lt;/td&gt;
&lt;td&gt;71.7 MB&lt;/td&gt;
&lt;td&gt;51.3 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Fedora dropped the most. Ubuntu dropped a lot less.&lt;/p&gt;

&lt;p&gt;The vulnerability findings were satisfactory as well. Both Grype and Trivy had no fixable high- or critical-level findings reported on the 16 hardened image and architecture combinations benchmark. I was careful in my wording: there still were findings, and it would not be right to call these images vulnerability-free.&lt;/p&gt;

&lt;p&gt;But then I compared the micro images from the hardened with the official minimal images (not the standard images), and the story changed. The AlmaLinux 9 hardened micro image was 51.3 MB, and the official minimal image was 36.2 MB, so the hardened image is about 42% bigger. Further investigation is definitely needed for the RPM images.&lt;/p&gt;

&lt;p&gt;I could have just published the comparisons to the normal upstream images, and the size reductions would have looked consistently impressive. That wouldn’t have been a useful benchmark. The comparison they will care about is with the official minimal image they are already using. And for me as an engineer, knowing where the project fails is more useful than adding another positive statistic to the collection.&lt;/p&gt;

&lt;p&gt;The results are available on the &lt;a href="https://iamenr0s.github.io/docker-hardened-images/" rel="noopener noreferrer"&gt;public benchmark dashboard&lt;/a&gt; and the methodology and supporting evidence are documented in the repository. Right now, the benchmark only runs on four of the supported versions of the distribution, and I want to expand that before making any sweeping conclusions about the whole catalog.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where I am taking the project
&lt;/h2&gt;

&lt;p&gt;There are a couple of things that still do not make me happy. One is to build reproducibility, and the other is the reliability of automated remediation. The engineering review also identified overdue vulnerability exception reviews and opportunities to improve publication controls and provenance verification. Not exciting to write about here. But it does matter if the project is going to be useful outside of my own environment.&lt;/p&gt;

&lt;p&gt;In retrospect I don’t think I had smaller Docker images in mind when I started this project. I wanted to have more control over the software that was under my applications and to better understand the risks I was taking on. This led to the smaller images, the automated maintenance workflows, and the supply chain verification.&lt;/p&gt;

&lt;p&gt;I want Docker Hardened Images to be more than another project that claims it provides secure containers but doesn’t provide enough information for people to be able to call that statement into question. I prefer to publish the measurements, explain the decisions, and let other engineers see the evidence themselves.&lt;/p&gt;

&lt;p&gt;The project is open source and also published under the MIT license. If you are working on container security or maintaining internal base images, or are just curious about how Linux root filesystems are built, I’d love to hear your feedback, especially if you see something I missed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/iamenr0s/docker-hardened-images" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://iamenr0s.github.io/docker-hardened-images/" rel="noopener noreferrer"&gt;Public benchmark dashboard&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/iamenr0s/docker-hardened-images/blob/main/docs/ENGINEERING-EVIDENCE.md" rel="noopener noreferrer"&gt;Engineering evidence and known limitations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/iamenr0s/docker-hardened-images/actions/runs/46780491664" rel="noopener noreferrer"&gt;Benchmark execution&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This is the first article in Engineering Trust, a five-part series about building and maintaining Docker Hardened Images.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Next week, I will look at something that deserves a much more nuanced discussion: Why Zero CVEs Is the Wrong Container Security Metric.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>opensource</category>
      <category>security</category>
    </item>
  </channel>
</rss>
