Cloud FinOps & Infrastructure ScalingPlaybook3 min readUpdated September 2026

Container Security: What Actually Stops an Attacker

Container security gets treated as a single checkbox, scanned or not scanned, when it's actually several distinct layers that each fail independently: the base image, the build pipeline, the runtime configuration, and the running container's actual behavior in production. A team can pass every image scan and still get compromised through a runtime misconfiguration that scanning never looked at.

Hardening means closing all four layers, not picking the easiest one and calling the job done.

Vendors Covered in this Article

Disclosure: We may earn a commission if you buy through some links on this page. It doesn't change what we recommend.

Why should container hardening start with the base image?

Every vulnerability in a base image ships into every container built on top of it, which is why minimal base images, ones stripped of package managers, shells, and anything not strictly required at runtime, matter more than almost any other single hardening decision. A smaller image isn't just faster to pull, it's a smaller attack surface: there's less installed software to carry a vulnerability, and less available to an attacker who does get in, like a shell to move around with. Pin base image versions explicitly and rebuild on a schedule rather than only when a vulnerability is discovered.

Scan the build pipeline, not just the final image

Image scanning catches known vulnerabilities in the final artifact, but it doesn't catch a compromised dependency pulled in during the build, or a build step that has more access than it needs, to source code, to signing keys, to the registry it pushes to. Treat the build pipeline itself as a security boundary: scope its credentials to exactly what that specific build needs, verify dependencies against a lockfile rather than pulling the latest version at build time, and log every image that gets pushed with enough detail to trace it back to the exact commit and pipeline run that produced it.

What does image scanning miss that runtime hardening catches?

A perfectly scanned, vulnerability free image can still run with a misconfiguration that hands an attacker far more than intended: running as root inside the container, mounting the host's Docker socket, or granting capabilities the workload never actually uses. None of these show up in an image scan, because they're properties of how the container runs, not what's inside it. Default to running as a non root user, drop all capabilities and add back only what's specifically needed, and treat any container that needs privileged mode as a special case requiring explicit justification, not a default convenience.

Check these runtime settings, which an image scan never sees:

  • Whether the container runs as root inside the container when the workload doesn't need that.
  • Whether the host's Docker socket is mounted into the container, which hands an attacker far more than intended.
  • Whether the container is granted capabilities the workload never actually uses.
  • Whether the deployment manifest mounts the host filesystem or requests privileged mode.
  • Whether runtime detection exists to catch unexpected processes, network connections or file system changes.

Patch on the clock that matches real world exploitation

Container vulnerabilities don't wait for your next scheduled rebuild, and the gap between a vulnerability becoming known and being actively exploited keeps shrinking. Federal guidance on known exploited vulnerabilities is a useful benchmark: those assigned a CVE since 2021 carry a fourteen day remediation clock, while older, pre-2021 known exploited vulnerabilities get a much longer window of up to 180 days1. Any container running in production with a known exploited vulnerability past that window is running on borrowed time, and automated rebuild pipelines triggered by new CVE disclosures close that gap far more reliably than a manual, periodic rebuild schedule.

Watch what's actually running, not just what you deployed

Runtime detection, catching unexpected process execution, unexpected network connections, or file system changes inside a running container, is what catches the compromise that got past every earlier layer. This is where platforms like CrowdStrike and Tenable diverge in focus: CrowdStrike leans toward real time runtime detection and response, Tenable leans toward continuous vulnerability and configuration visibility across the fleet. Neither replaces the earlier layers, a minimal image, a scoped build pipeline, hardened runtime configuration, they catch what gets through despite those layers being in place.

The mistake of hardening the image and shipping an open deployment manifest

It's common for a team to spend real effort minimizing a base image and locking down the build pipeline, then deploy that same hardened image with a manifest that mounts the host filesystem, requests privileged mode out of habit, or skips setting a non root user because the original manifest never had one. All of that image level work is wasted the moment the deployment configuration hands an attacker a path around it. Review the deployment manifest itself as part of the same hardening pass, not as a separate, later concern owned by a different team: the two layers only protect anything when they're both closed at once.

Executive Capability Standard

What Good Looks Like

Good container hardening means a minimal, version pinned base image, a scoped and logged build pipeline, non root runtime configuration by default, and runtime detection catching what gets through the earlier layers.

Building The Capability (5-Stage Skill Ladder)

1. Learn:Audit your current base images for unnecessary installed packages and check whether any production containers are currently running as root.
2. Do Manually:Manually rebuild one high traffic image on a minimal base and confirm it still runs correctly before rolling the pattern out further.
3. Delegate:Assign an owner for base image maintenance and the rebuild schedule so it doesn't only happen reactively after a vulnerability is found.
4. Automate:Automate rebuilds triggered by new CVE disclosures in your base image rather than relying on a fixed calendar schedule.
5. Buy:Bring in a runtime detection platform once you need visibility into container behavior in production, not just what's in the image before it ships.

How to Get Started

Disclosure: We may earn a commission if you buy through some links on this page. It doesn't change what we recommend.

Frequently Asked Questions

Is image scanning enough on its own to call containers hardened?

No. Image scanning is necessary but only covers known vulnerabilities in what's installed, it doesn't catch runtime misconfigurations like running as root or mounting the host socket, and it doesn't catch build pipeline compromises. Treat scanning as one of four layers, base image, build pipeline, runtime configuration, and runtime behavior, not the whole solution.

Should every container run as non root?

As close to always as possible. The rare exception is a workload with a specific, documented reason it needs elevated privileges, and even then the scope should be as narrow as possible rather than full root. Defaulting every container to non root and only granting elevated access with explicit justification catches most privilege related misconfigurations before they ship.

How fast should we rebuild after a new CVE is disclosed for something in our base image?

Fast enough to beat real world exploitation, which for a known exploited vulnerability assigned since 2021 is a fourteen day outside bound under federal guidance, not a target to aim for but a latest acceptable point. An automated pipeline that rebuilds and redeploys on new CVE disclosure in your base image will consistently beat a manual, calendar based rebuild schedule.

Sources

Where we quote a benchmark, we show its source. Other figures in this guide are estimates or general guidance, so check them against your own numbers.

  1. Security patch remediation SLAs (CISA federal mandates, used as industry norm). CISA Binding Operational Directives 19-02 and 22-01 (CISA briefing hosted at NIST CSRC), 2022.

Related Guides