<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/securing-docker-images-harden-patch-and-maintain-them-fnqtjltzh" -->

---
title: Securing Docker images: harden, patch, and maintain them
description: Most vulnerabilities in a Docker image come from the base OS layer rather than application code. Hardening involves shrinking the attack surface (minimal...
canonical: https://daily.dev/posts/securing-docker-images-harden-patch-and-maintain-them-fnqtjltzh
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Securing Docker images: harden, patch, and maintain them | daily.dev
og:description: Most vulnerabilities in a Docker image come from the base OS layer rather than application code. Hardening involves shrinking the attack surface (minimal...
og:url: https://daily.dev/posts/securing-docker-images-harden-patch-and-maintain-them-fnqtjltzh
og:image: https://api.daily.dev/og/posts/FNqtJlTZh.png
og:image:alt: Securing Docker images: harden, patch, and maintain them
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Securing Docker images: harden, patch, and maintain them

**[Aikido Security](https://daily.dev/sources/aikido-security)** · 17 min read · 0 upvotes · 0 comments

## Summary

Most vulnerabilities in a Docker image come from the base OS layer rather than application code. Hardening involves shrinking the attack surface (minimal bases, multi-stage builds, removing unused packages), setting correct permissions (non-root, read-only filesystem, dropped capabilities), keeping secrets out of layers, pinning base images by digest, and continuously verifying with SBOMs and image signing. Because new CVEs are disclosed continuously against packages already inside a shipped image, hardening is framed as an ongoing vulnerability management process rather than a one-time build step. Three approaches to keeping a base patched are covered: manual maintenance, migrating to a vendor's rebuilt hardened distribution, or using a tool that patches the exact base version already in use. Aikido Images is presented as the third option, providing backported patches via pull request without forcing a migration to a new base.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.aikido.dev/blog/securing-docker-images>

## Questions this post answers

### Should Docker containers run as root?

No, containers should run as a non-root user unless something genuinely requires root. If an attacker gets code execution in the app, they inherit whatever privileges the container runs as, and root in the container combined with a container escape can mean root on the host. Set a dedicated non-root user in the Dockerfile and drop unused Linux capabilities like CAP_NET_RAW.

_Teams hardening Dockerfiles can track container security practices and CVE writeups on daily.dev._

### What's the difference between a minimal Docker image and a hardened Docker image?

A minimal image simply ships less, stripping shells, package managers, and libraries the app doesn't need, while a hardened image starts from a minimal base and goes further by applying patched package versions and secure defaults like non-root execution. Minimal shrinks the attack surface; hardened shrinks it and locks down what remains.

_Anyone comparing base image strategies can follow container hardening comparisons on daily.dev._

### Why can CISA recommend downgrading a package instead of upgrading it after a vulnerability is found, as happened with the xz-utils backdoor?

Because the malicious code was injected into two specific recent releases, 5.6.0 and 5.6.1, of the xz-utils compression library, while teams still on the older 5.4 line were never exposed. CISA's guidance after discovery was to downgrade rather than upgrade, since jumping to the newest release is not automatically the safer choice.

_Developers weighing upgrade versus rollback decisions can follow supply chain security incidents on daily.dev._

## Similar posts on daily.dev

- [Hardened Images Explained](https://daily.dev/posts/hardened-images-explained-qexp0th6y) · Docker · 2 upvotes · 1 comments
- [Hardening the Core: Container Validation and Malicious Package Defense](https://daily.dev/posts/hardening-the-core-container-validation-and-malicious-package-defense-fm50k0pnh) · Container Journal · 0 upvotes · 0 comments

---

Tags: [#security](https://daily.dev/tags/security), [#docker](https://daily.dev/tags/docker), [#containers](https://daily.dev/tags/containers), [#sbom](https://daily.dev/tags/sbom)

[View this post on daily.dev](https://daily.dev/posts/securing-docker-images-harden-patch-and-maintain-them-fnqtjltzh)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Securing Docker images: harden, patch, and maintain them","url":"https://daily.dev/posts/securing-docker-images-harden-patch-and-maintain-them-fnqtjltzh","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/securing-docker-images-harden-patch-and-maintain-them-fnqtjltzh"},"datePublished":"2026-08-28T21:45:03.095Z","dateModified":"2026-09-14T08:08:32.515Z","description":"Most vulnerabilities in a Docker image come from the base OS layer rather than application code. Hardening involves shrinking the attack surface (minimal...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f0e170f55760aea96a967125aa4313fe?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f0e170f55760aea96a967125aa4313fe?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Aikido Security","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Aikido Security","logo":"https://media.daily.dev/image/upload/s--vJDqDYv_--/f_auto,q_auto/v1774959928/logos/aikido-security?_a=BAMAMiWQ0","url":"https://daily.dev/sources/aikido-security"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/securing-docker-images-harden-patch-and-maintain-them-fnqtjltzh","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"security,docker,containers,sbom","timeRequired":"PT17M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Aikido Security","item":"https://daily.dev/sources/aikido-security"},{"@type":"ListItem","position":3,"name":"Securing Docker images: harden, patch, and maintain them"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/securing-docker-images-harden-patch-and-maintain-them-fnqtjltzh#faq","mainEntity":[{"@type":"Question","name":"Should Docker containers run as root?","acceptedAnswer":{"@type":"Answer","text":"No, containers should run as a non-root user unless something genuinely requires root. If an attacker gets code execution in the app, they inherit whatever privileges the container runs as, and root in the container combined with a container escape can mean root on the host. Set a dedicated non-root user in the Dockerfile and drop unused Linux capabilities like CAP_NET_RAW. Teams hardening Dockerfiles can track container security practices and CVE writeups on daily.dev."}},{"@type":"Question","name":"What's the difference between a minimal Docker image and a hardened Docker image?","acceptedAnswer":{"@type":"Answer","text":"A minimal image simply ships less, stripping shells, package managers, and libraries the app doesn't need, while a hardened image starts from a minimal base and goes further by applying patched package versions and secure defaults like non-root execution. Minimal shrinks the attack surface; hardened shrinks it and locks down what remains. Anyone comparing base image strategies can follow container hardening comparisons on daily.dev."}},{"@type":"Question","name":"Why can CISA recommend downgrading a package instead of upgrading it after a vulnerability is found, as happened with the xz-utils backdoor?","acceptedAnswer":{"@type":"Answer","text":"Because the malicious code was injected into two specific recent releases, 5.6.0 and 5.6.1, of the xz-utils compression library, while teams still on the older 5.4 line were never exposed. CISA's guidance after discovery was to downgrade rather than upgrade, since jumping to the newest release is not automatically the safer choice. Developers weighing upgrade versus rollback decisions can follow supply chain security incidents on daily.dev."}}]}
```

