What if the biggest hole in your security program is the thing your team deploys ten times a day? Containers make software faster to ship, but they also widen the attack surface in ways many teams never audit. The good news is that container security is not a single product you buy. It is a layered process that starts with a minimal image and ends with runtime monitoring. (Best internet security australia) (Kubernetes Documentation: Security)
This guide walks through a practical setup, from base images to cluster policies. It focuses on what actually works in production, the mistakes that keep showing up in audits, and the order in which to fix them.
Why container security needs its own playbook
Traditional server security assumed long-lived machines that were patched slowly and guarded by a firewall. Containers break that model. They are ephemeral, they share a kernel, and they are often pulled from public registries by developers who are moving fast.
The National Institute of Standards and Technology laid out the risk landscape in its Application Container Security Guide (NIST SP 800-190, published September 2017). It groups container risks into five lifecycle areas: image, registry, orchestrator, container, and host operating system. That structure is useful because it forces you to think beyond the container itself.
Two points from that guidance matter most in practice. First, image vulnerabilities and badly configured images are core risks, which is why scanning and minimal base images are non-negotiable. Second, the host operating system still counts. A compromised host means every container on it is compromised too.
Step 1: Start with a minimal, trusted base image

Most container incidents begin with the image. The fastest win is to shrink it.
Choose a minimal base image such as Alpine, distroless, or a slim variant of your language runtime. Fewer packages mean fewer vulnerabilities and a smaller patch surface. Then pin the image by digest rather than a floating tag like `latest`, so what you tested is exactly what you deploy.
From there, the setup order looks like this:
- Build images from a trusted, minimal base and pin digests.
- Run as a non-root user inside the container whenever the workload allows it.
- Drop Linux capabilities you do not need, and set the filesystem to read-only where possible.
- Scan every image in CI before the first release and on every later build.
- Sign images and verify signatures before admission to the cluster.
Image signing and attestation work across registries and runtimes because the Open Container Initiative image specification defines a common format. That shared format is what lets tools like Sigstore and cosign verify an image no matter where it runs.
For supply chain integrity, the SLSA framework gives you build provenance levels to aim for; SLSA v1.0 was released in April 2023. Even reaching a basic provenance level is a meaningful upgrade over trusting whatever lands in the registry.
Step 2: Harden the container runtime and host
The container is only as safe as the engine and the machine beneath it. This is where teams skip steps, and it shows.
The CIS Docker Benchmark provides prescriptive checks for host and daemon hardening. Common items include restricting access to the Docker socket, enabling user namespaces, and turning on auditing. The Docker socket deserves special attention: anyone who can talk to it can usually root the host.
Practical hardening steps for the runtime layer:
- Restrict who can reach the Docker daemon socket, and never expose it over a network without TLS and authentication.
- Enable user namespaces so container root is not host root.
- Apply seccomp and AppArmor or SELinux profiles rather than running unconfined.
- Keep the host kernel and container engine patched on a schedule you actually follow.
- Separate workloads onto dedicated hosts when they have very different trust levels.
A mistake that recurs in real environments is treating the host as disposable infrastructure while leaving its kernel years out of date. Containers share that kernel. Patching the host is container security.
Step 3: Lock down the orchestrator with policy
If you run Kubernetes, the orchestrator is where policy becomes enforceable. Kubernetes introduced Pod Security Standards as a built-in admission feature in v1.23 (December 2021), replacing the older PodSecurityPolicy that was deprecated in v1.21 and removed in v1.25 (August 2022). The standards come in three tiers: Privileged, Baseline, and Restricted.
A sensible path is to start namespaces at Baseline, then move production workloads to Restricted. The Restricted profile blocks privileged containers, requires non-root execution, and enforces seccomp profiles. It will break some workloads at first, which is exactly why you roll it out namespace by namespace rather than flipping a cluster-wide switch.
The table below summarizes how the tiers compare for typical teams:
| Tier | What it blocks | Best fit | Rollout risk |
|---|---|---|---|
| Privileged | Almost nothing | System and infrastructure add-ons | Low |
| Baseline | Known privilege escalations | General workloads, staging | Medium |
| Restricted | Privileged mode, root, weak seccomp | Production, regulated data | High at first |
Beyond pod security, restrict what containers can reach. NetworkPolicy is a stable API for limiting pod-to-pod traffic, but enforcement depends entirely on your CNI plugin. A policy with no enforcing plugin has no effect at all, a trap that catches teams who assume the YAML is doing something.
The CISA and NSA Kubernetes Hardening Guidance (August 2022) covers pod security, network separation, and authentication in one place. It is a good checklist to compare against your cluster configuration.
Step 4: Secure the registry and the supply chain
The registry is the handoff point between developers and production, so it deserves its own controls.
Start with access control. Use least-privilege credentials for pushing and pulling, and separate the accounts that publish images from the ones that deploy them. Enable vulnerability scanning at the registry level so an image that slips past CI still gets flagged.
Then add provenance. The NSA and CISA software supply chain guidance (January 2022) addresses integrity and provenance for build pipelines, which is directly relevant to image signing. The principle is simple: only deploy artifacts whose origin you can verify.
A practical registry setup includes:
- Immutable tags so published images cannot be silently overwritten.
- Retention policies that remove stale images and reduce clutter.
- Admission control that rejects unsigned or unscanned images.
- Audit logging on pulls and pushes for sensitive repositories.
If you are also hardening the endpoints and networks around your build systems, the same discipline applies as with home security systems: layers matter more than any single control. The same layered thinking shows up when teams compare non-human identity security platforms, where the question is always which layer enforces the boundary.
Step 5: Add runtime detection and response
Configuration prevents problems. Runtime detection catches the ones that get through.
At minimum, monitor for unexpected process execution, outbound connections to unknown hosts, and privilege escalation attempts inside containers. Because containers are ephemeral, log collection has to happen at the node or through a sidecar rather than by logging into the container.
Keep the response plan simple. Define what happens when an alert fires: isolate the pod, capture the image digest, and trace back to the build. Teams that skip this step end up with alerts nobody acts on.
One more practical note: set resource limits. A container without CPU and memory limits can starve its neighbors, and that is an availability problem that looks like a security incident when it happens at 2 a.m. (Rules for Backgammon Board Game: How to Set Up and Play)
Common mistakes that undermine container security
Even well-funded teams repeat the same errors. Watch for these:
- Running as root by default. It is the path of least resistance and the most common finding in audits.
- Trusting the `latest` tag. It makes rollbacks and incident tracing nearly impossible.
- Assuming NetworkPolicy works without checking the CNI. Verify enforcement with a real connection test.
- Scanning only at build time. New vulnerabilities appear in old images every week.
- Ignoring the host. Kernel patches and engine updates are part of the container security program.
- Skipping the rollback plan. A policy that breaks production gets disabled, and then nothing is enforced.
The pattern behind all of these is treating container security as a one-time project. It is a loop: build, scan, sign, deploy, monitor, patch, repeat.
How to prioritize when you cannot do everything
Most teams cannot implement every control at once. A reasonable sequence is:
- Scan images in CI and block critical vulnerabilities.
- Stop running containers as root.
- Pin image digests and enable registry scanning.
- Apply Baseline pod security to all namespaces.
- Enforce NetworkPolicy with a CNI that supports it.
- Add image signing and admission verification.
- Turn on runtime detection and write the response runbook.
This order front-loads the controls with the best ratio of risk reduction to effort. It also builds momentum, because each step produces visible results that make the next conversation easier. (Horse Racing Board Game: Family Racing Game Set)
Conclusion
Container security is a stack of small, verifiable decisions rather than a single purchase. Start with minimal, pinned base images. Harden the runtime and the host beneath it. Enforce pod security standards and network policy in the orchestrator. Verify provenance at the registry. Then watch what actually runs, and keep the loop going.
The teams that get this right share one habit: they treat every layer as something to test, not something to assume. A policy that is not enforced is just documentation. A scan that nobody reads is just a log line. Set up the controls, then prove they work.
Frequently asked questions
What is container security?
Container security is the practice of protecting containerized workloads across their whole lifecycle: the image, the registry, the orchestrator, the running container, and the host operating system. NIST SP 800-190 uses exactly these five areas to organize container risks, and it is a useful mental model for planning controls.
Should containers run as root?
No, not if you can avoid it. Running as a non-root user limits what an attacker can do after a compromise and is required by the Kubernetes Restricted pod security profile. Some workloads need specific user IDs to function, so test carefully, but the default should be non-root.
Does NetworkPolicy work out of the box in Kubernetes?
Not necessarily. NetworkPolicy is a stable API, but enforcement depends on the CNI plugin installed in your cluster. If your plugin does not support policy enforcement, the objects are accepted and then ignored. Always verify with a real connection test rather than trusting that the YAML took effect.
How often should container images be scanned?
Scan at build time and continuously afterward. New vulnerabilities are disclosed in packages that were clean when the image was built, so a one-time scan gives you a false sense of safety. Continuous registry scanning plus a rebuild cadence keeps images current.
What is the difference between Baseline and Restricted pod security?
Baseline blocks known privilege escalations while staying broadly compatible with common workloads. Restricted goes further, requiring non-root execution, blocking privileged mode, and enforcing seccomp profiles. Most teams run Baseline in staging and Restricted in production.
Do I need image signing if I already scan images?
Yes, because they solve different problems. Scanning tells you whether an image has known vulnerabilities. Signing tells you whether the image you are deploying is the one your pipeline built. Supply chain guidance from CISA and the NSA treats provenance as a separate control from vulnerability management.
How long does it take to set up container security?
A basic baseline, covering image scanning and non-root execution, can be in place in days. Full hardening across the orchestrator, registry, and runtime typically takes weeks to months, depending on cluster size and how many teams own workloads. Prioritize by risk and roll out namespace by namespace.


