Containers make it easy to ship software consistently, and just as easy to ship vulnerabilities consistently. A single base image with an outdated library can end up in hundreds of services. Container security is about controlling what goes into images, what is allowed to run, and what it is allowed to do once running.
Kubernetes adds its own layer: cluster configuration, permissions and network policies all affect how far an attacker could move if one workload were compromised.
Build: secure images
Start from minimal, trusted base images such as distroless or slim variants, and keep them up to date. Scan every image for known vulnerabilities at build time and again regularly, because new CVEs are published every day. Never bake secrets into images.
Generate an SBOM for each image and sign images so the cluster can verify where they came from.
- Minimal base image
- Fewer packages means fewer vulnerabilities and less for an attacker to use.
- Image signing
- Cryptographic proof that an image came from your pipeline, for example with Sigstore Cosign.
Deploy: admission control
Admission controllers such as OPA Gatekeeper or Kyverno check every workload before it runs. Typical rules: no containers running as root, no privileged containers, images only from approved registries, signatures required, and resource limits set.
Start in audit mode to see what would be blocked, fix the existing workloads, then switch to enforcement.
Runtime: detect and contain
Runtime tools such as Falco watch system calls and process activity for suspicious behaviour, like a shell spawned inside a container or unexpected writes to the file system. Network policies limit which pods can talk to each other, so a compromised workload can't reach everything.
Combine runtime detection with fast response: the ability to isolate or kill a pod and redeploy a clean version within minutes.
Cluster and supply-chain hygiene
Keep Kubernetes versions supported, restrict access to the API server, use role-based access control with least privilege, and prefer workload identity over long-lived credentials. Managed services such as EKS, AKS, GKE or Cloud Run take some of this burden off your team.
Supply-chain frameworks such as SLSA describe levels of build integrity. Even reaching the first levels, with scripted builds and provenance, closes many common attack paths.
Who owns what
Container security works best when responsibilities are clear. The platform team owns base images, cluster configuration, admission policies and runtime detection. Application teams own their dependencies, their own image layers and fixing vulnerabilities in their services within agreed times.
Make this visible on a simple dashboard per team: vulnerable images, policy violations and age of base images. Teams fix what they can see, and a little friendly comparison between teams often helps.
How to put it into practice
- Standardise on a small set of minimal, regularly rebuilt base images.
- Scan images in the pipeline and on a schedule in your registry.
- Run an admission controller in audit mode, fix violations, then enforce the top rules.
- Add network policies, starting with deny-by-default in sensitive namespaces.
- Deploy runtime detection on production clusters and route alerts to the owning team.
- Sign images and verify signatures at admission.
Common mistakes
- Scanning images once at build and never again.
- Running containers as root because it was the default.
- Flat cluster networking where every pod can reach every other pod.
- Storing secrets in images or environment files committed to Git.
How to measure progress
- Critical vulnerabilities in running images, and time to patch.
- Share of workloads passing admission policies.
- Share of namespaces with network policies.
- Age of base images in production.