Cloudanix Joins AWS ISV Accelerate Program

Cloudanix – Your Partner in Cloud Security Excellence

Top 12 Container Security Best Practices

  • Abhiram Shindikar Abhiram Shindikar
  • Tuesday, Apr 09, 2024

Updated August 2026: This article was originally published in April 2024 and has been comprehensively updated to reflect the latest container security practices, including supply chain attestation, eBPF-based runtime security, admission policy enforcement, and workload identity federation as of 2026.

Introduction

The process of protecting containerized applications from possible threats is known as container security. These containerized applications are vulnerable to more than just CVEs in base images — they face misconfigured containers, lack of isolation, supply chain attacks, runtime compromise, privilege escalation, and container escape exploits.

Container adoption is now the default for microservices architectures. Kubernetes orchestrates workloads across EKS, AKS, GKE, and self-managed clusters. With this ubiquity comes a broader attack surface and a more sophisticated threat landscape.

In this guide, we cover 12 container security best practices organized by priority — from the foundational practices that prevent the most impactful attacks, to the operational practices that maintain long-term resilience. These practices are informed by real-world incidents, CIS Kubernetes benchmarks, and the NIST SP 800-190 container security guide.


High Priority

1. Enforcing the Least Privilege Principle

The least privilege principle minimizes the potential damage caused by a compromised container. With least privilege, a workload (or user) gets access to only the services required to perform their tasks. If an attacker compromises a container, they gain minimal ability to move laterally or escalate privilege.

Implementation details:

  • Run containers as non-root: Define runAsNonRoot: true and set a specific runAsUser in your pod security context. Most containerized applications do not need root access.
  • Drop all Linux capabilities and add back only what is needed: Start with drop: ["ALL"] and selectively add capabilities like NET_BIND_SERVICE if the application specifically requires them.
  • Use read-only root filesystems: Set readOnlyRootFilesystem: true to prevent attackers from modifying binaries or writing malware to the container filesystem.
  • Limit resource access: Define CPU and memory limits to prevent resource abuse (e.g., cryptomining). Define network policies to restrict pod-to-pod communication.
  • Service account scoping: Each workload should have its own Kubernetes service account with only the RBAC permissions it genuinely needs. Never use the default service account.

Extending least privilege to identity:

For human access to clusters, implement Kubernetes JIT — ephemeral kubeconfig that auto-expires. Engineers get cluster access only when needed, for as long as needed, with full audit trail. This eliminates standing kubectl access that persists indefinitely.

For workloads, use IAM Roles for Service Accounts (IRSA on EKS), Workload Identity (GKE), or AAD Pod Identity (AKS) to grant cloud permissions to pods without static credentials.

2. Ensure Secure Container Images

Vulnerable container images are prime targets for attackers. A single vulnerable dependency in a base image can affect every workload built from it. You can mitigate these risks through disciplined image hygiene.

Trusted base images:

  • Obtain container images from official registries and trusted vendors only (Docker Official Images, Chainguard, Google Distroless)
  • Use minimal base images — Alpine, Distroless, or Scratch images have smaller attack surfaces than full OS images (Ubuntu, Debian)
  • Pin image tags to specific digests rather than mutable tags like latest

Image scanning in CI and runtime:

  • Scan images for vulnerabilities during the build phase (shift-left) — catch issues before they reach any registry
  • Re-scan images in the registry continuously — new CVEs are disclosed daily, and yesterday’s clean image may have a critical vulnerability today
  • Scan running container images to identify drift between what was deployed and what is currently running

Multi-stage builds:

Use multi-stage Docker builds where each stage builds upon the previous one. The final production image contains only the compiled application and its minimal runtime dependencies — no build tools, no compilers, no package managers that attackers could abuse.

# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build

# Production stage — minimal surface
FROM gcr.io/distroless/nodejs20-debian12
COPY --from=builder /app/dist /app
CMD ["/app/server.js"]

Image signing and attestation:

In 2026, best practice goes beyond scanning — it includes cryptographic attestation:

  • Sign images with Sigstore/cosign: After build and scan, sign the image. This creates a verifiable chain of custody.
  • Generate and attach attestation: Attach build provenance (SLSA), vulnerability scan results, and SBOM as signed attestations to the image.
  • Enforce signatures at admission: Configure admission controllers (Kyverno, Connaisseur) to reject any image that lacks a valid signature or attestation.

3. Reducing the Attack Surface

A smaller attack surface means fewer potential entry points for attackers. Eliminating unnecessary processes and components reduces the risk of vulnerabilities being exploited.

Practical attack surface reduction:

  • Remove unnecessary packages: If your container doesn’t need curl, wget, or bash, don’t include them. Every binary is a tool an attacker can use post-compromise.
  • No package managers in production: Remove apt, apk, yum from final images. This prevents attackers from installing additional tools.
  • Single process per container: Run one process per container. This limits blast radius and makes behavioral monitoring more effective — any unexpected process is immediately suspicious.
  • Disable unnecessary network interfaces: If a container only needs to communicate over specific ports, bind only to those ports.
  • Eliminate debug/diagnostic endpoints: Production containers should not expose profiling, debugging, or health-check endpoints that reveal internal state.

Container hardening with security contexts:

securityContext:
  runAsNonRoot: true
  runAsUser: 1000
  allowPrivilegeEscalation: false
  readOnlyRootFilesystem: true
  capabilities:
    drop: ["ALL"]
  seccompProfile:
    type: RuntimeDefault

This security context eliminates privilege escalation paths, prevents filesystem modification, drops all Linux capabilities, and applies the default seccomp profile to restrict system calls.

4. Implement Network Segmentation

Network segmentation prevents lateral movement within the cluster. If one container is compromised, network policies ensure the damage is contained and other services are not affected.

Kubernetes Network Policies:

  • Default deny all ingress and egress: Start with a deny-all policy for each namespace, then explicitly allow only the communication paths your application requires.
  • Namespace isolation: Separate environments (dev, staging, prod) into different namespaces with strict network boundaries.
  • Pod-level policies: Define policies at the pod selector level, not just namespace level. A compromised pod should not be able to reach unrelated services in the same namespace.

Cilium for advanced network security:

In 2026, Cilium (eBPF-based networking) has become the standard CNI for security-focused Kubernetes deployments. Beyond traditional L3/L4 policies, Cilium provides:

  • L7 policy enforcement: Restrict traffic at the HTTP/gRPC level (allow GET /api/health but deny POST /admin)
  • DNS-aware policies: Control egress based on DNS names, not just IP addresses
  • Identity-based segmentation: Define policies based on pod identity rather than IP addresses (which are ephemeral in Kubernetes)
  • Network flow visibility: Complete visibility into every connection attempt, successful or blocked

5. Secrets Management

Storing sensitive information like usernames, passwords, or API keys in your containers is a significant security risk that most organizations overlook. Container images in registries can be pulled by anyone with access, exposing all embedded secrets.

Best practices for container secrets:

  • Never embed secrets in images: Not in environment variables baked into the Dockerfile, not in configuration files copied into the image, not in code committed to the repository.
  • Use external secrets management: Integrate with HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, or GCP Secret Manager. Secrets are injected at runtime, not at build time.
  • Kubernetes secrets with encryption at rest: While Kubernetes Secrets are base64-encoded (not encrypted) by default, enable encryption at rest and consider using the Secrets Store CSI Driver to mount secrets from external providers.
  • Rotate secrets automatically: Implement automated rotation. When a secret is compromised, the rotation window determines your exposure time.
  • Eliminate shared database passwords: Rather than sharing a single database credential across all pods, use Database JIT access — each session gets a unique, identity-stamped, time-bound credential. No shared passwords to leak.

Medium Priority

6. Integrating Robust Container Security Tools

Container security tools provide vulnerability scanning, runtime protection, policy enforcement, and threat detection capabilities that enhance your overall security posture.

Evaluating container security tooling:

When selecting a container security platform, consider:

  • Coverage depth: Does it cover the full lifecycle — build, registry, deployment, runtime? Or only one stage?
  • Multi-cluster support: Can it handle EKS, AKS, GKE, and self-managed clusters from a single console?
  • Integration with your existing workflow: Does it post findings as PR comments? Does it integrate with Slack, Jira, PagerDuty?
  • Contextual prioritization: Does it correlate container vulnerabilities with identity permissions, network exposure, and data sensitivity? A critical CVE in an air-gapped pod with no IAM role is different from the same CVE on an internet-facing pod with admin access.
  • Signal-to-noise ratio: How many findings are actionable versus noise? Adaptive notification management (auto-snooze, deduplication) prevents alert fatigue.

Cloudanix’s container security provides integrated scanning across the full lifecycle, correlated with the broader cloud security graph — so container findings are enriched with identity context, network reachability, and compliance mapping from the same platform that handles CSPM and CIEM.

7. Updating and Patching Regularly

Addressing vulnerabilities promptly and applying security patches reduces the risk of attackers exploiting known issues. In the container world, patching means rebuilding images — not running apt update inside a running container.

Patching strategy for containers:

  • Automate base image updates: Use tools like Renovate or Dependabot to automatically propose PRs when base image updates are available.
  • Rebuild, don’t patch in place: Containers are immutable. When a vulnerability is discovered, rebuild the image with the patched dependency, push to registry, and redeploy. Never SSH into a running container to apply patches.
  • Define SLAs by severity: Critical vulnerabilities with known exploits: patch within 24–72 hours. High vulnerabilities: patch within 1–2 weeks. Medium/Low: address in the next release cycle.
  • Track patch coverage: Monitor what percentage of your running containers are built from the latest patched image. Stale deployments with unpatched images are a common blind spot.

8. Protecting Container Orchestration

Securing your container orchestration platform (Kubernetes) is compulsory — it manages and controls container deployments, scaling, and networking. A compromised cluster API server gives attackers control over every workload.

Kubernetes control plane security:

  • API server access control: Restrict API server access to specific CIDR ranges. Use RBAC with least-privilege roles. Enable audit logging for all API calls.
  • etcd encryption: Enable encryption at rest for etcd (the Kubernetes backing store). All secrets, configmaps, and cluster state lives in etcd.
  • Admission controllers: Deploy and configure admission controllers that enforce security policies at deployment time:
    • Kyverno: Policy-as-YAML, no new language to learn. Generate, validate, and mutate resources.
    • OPA Gatekeeper: Rego-based policies for complex logic. Constraint templates provide reusability.
  • Pod Security Standards (PSS): Enforce Baseline or Restricted security standards at the namespace level. Privileged pods should be the exception, not the default.
  • RBAC hygiene: Regularly audit RBAC bindings. Remove stale bindings. Never grant cluster-admin to service accounts. Use namespace-scoped roles rather than cluster roles where possible.

Securing managed Kubernetes:

For managed services (EKS, AKS, GKE):

  • Keep the cluster version current (within one minor version of latest)
  • Enable control plane logging and ship logs to your SIEM
  • Use private cluster endpoints where possible — no public API server access
  • Enable Security Groups for Pods (EKS) or similar network isolation at the pod level

9. Admission Policy Enforcement

Beyond basic admission controllers, implement comprehensive policy enforcement that catches misconfigurations before they become running workloads.

Policy categories to enforce:

  • Image policies: Only allow images from approved registries; require image signatures; block images with critical CVEs
  • Workload policies: Require security contexts; block privileged containers; enforce resource limits; require liveness/readiness probes
  • Network policies: Require a NetworkPolicy for every namespace; block default-allow configurations
  • Label and annotation policies: Require ownership labels (team, service, environment) for accountability
  • Compliance policies: Map organizational compliance requirements (SOC 2, HIPAA, PCI) directly to admission policies

Low Priority

10. Preparing an Incident Response Plan

Having an incident response plan that outlines procedures for detection, containment, eradication, and recovery helps you respond effectively to container-specific security incidents.

Container-specific IR considerations:

  • Detection: What signals indicate a container is compromised? Unexpected processes, unusual network connections, filesystem writes to read-only paths, or anomalous API calls.
  • Containment: How do you isolate a compromised pod without affecting the rest of the service? Network policy quarantine, service mesh circuit-breaking, or pod deletion with investigation of the underlying node.
  • Evidence preservation: Containers are ephemeral — if you kill the pod, you lose the evidence. Capture container filesystem state, memory dump (if possible), and all relevant logs before remediation.
  • Scope assessment: If one pod is compromised, what else can the attacker reach? Service account permissions, network access, secrets mounted, and external service connections determine blast radius.

11. Regular Audits and Compliance

Conducting regular security audits of your containerized applications and infrastructure helps identify potential threats and vulnerabilities in your container environment.

Audit areas for containers:

  • CIS Kubernetes Benchmark: Run automated CIS benchmark checks against your clusters regularly (kube-bench)
  • Image freshness: What percentage of running images are more than 30/60/90 days old?
  • RBAC audit: Who has access to what? Are there stale bindings? Are there cluster-admin bindings that shouldn’t exist?
  • Network policy coverage: What percentage of namespaces have explicit network policies?
  • Secrets audit: Are any secrets mounted that are no longer needed? Are any secrets older than the rotation window?
  • Compliance mapping: Map your container security posture to relevant frameworks (SOC 2, HIPAA, PCI, NIST) and generate audit-ready evidence

12. Continuous Integration/Delivery Security and Runtime Monitoring

Integrating security checks into your CI/CD pipelines helps identify threats and vulnerabilities early in your deployment lifecycle.

CI/CD pipeline security:

  • Scan at every stage: Source code (SAST), dependencies (SCA), container images (vulnerability scan), IaC (policy compliance), and deployment manifests (admission pre-check)
  • Break the build on critical issues: Define clear thresholds. A critical CVE in a production image should fail the pipeline.
  • Generate SBOM and sign artifacts: Every successful build should produce a signed SBOM and signed container image.
  • Secure the pipeline itself: CI/CD runners are high-value targets. Use ephemeral runners, restrict runner network access, and grant minimum IAM permissions. Ensure no long-lived credentials are stored in pipeline configurations.

Runtime monitoring and threat detection:

  • eBPF-based monitoring: Modern runtime security uses eBPF to observe system calls, network connections, and file access at the kernel level — without the overhead of traditional agents. This provides deep visibility into container behavior.
  • Behavioral baselines: Establish what “normal” looks like for each container (expected processes, network connections, file access patterns). Any deviation from baseline triggers an alert.
  • Intrusion detection/prevention (IDS/IPS): Detect and block known attack patterns — container escape attempts, cryptominer execution, reverse shells, and lateral movement.
  • Workload identity monitoring: Track which workload identities are being used, from where, and for what. Anomalous credential usage (a pod making IAM calls it never made before) is a high-fidelity signal.

Bringing It All Together

Security is an ongoing process, and the specific priority of these practices may vary depending on your unique risk profile and threat landscape. Continuously evaluate your security posture, adapt your strategies, and leverage these best practices to maintain a secure and resilient cloud container environment.

The most effective container security programs share a common trait: they don’t treat container security in isolation. A container vulnerability correlated with an over-privileged service account, internet exposure, and access to a sensitive database is a critical attack path. The same vulnerability in an air-gapped pod with no permissions is informational noise.

Along with CSPM and CIEM, Cloudanix provides an integrated container security platform that places your container findings on the same security graph as identity, posture, and code findings. Your team gets a real-time view of threats and vulnerabilities with contextual severity — so they can address the highest-risk findings first. Getting started takes less than five minutes with agentless onboarding.

People Also Read

What Our Users Are Saying

Customer Reviews

Cloudanix is trusted by security leaders worldwide to deliver proactive, reliable, and cutting-edge cloud security.

One day, I changed the password of a root account, and my CTO called me within less than a minute to confirm if I did so. I was not expecting a reaction this quick. He told me Cloudanix alerted him of this password change and that he wanted to confirm as it was a critical security notification. I couldn't believe it!

Ritesh Agarwal
Ritesh Agarwal
CEO, Airgap Networks

Compliance is one way of staying secure, but what I want is the ability to go deeper and attain 'true security.' Cloudanix provides us the capability to do so.

Vishal Madan
Vishal Madan
Head of Engineering, iMocha

Cloudanix is building for the future of the cloud, which makes the product all the more desirable.

Ritesh Agarwal
Ritesh Agarwal
CEO, Airgap Networks

Cloudanix gave us the visibility we were missing. Being able to move from permanent access to a robust Just-In-Time (JIT) workflow has fundamentally changed our security posture without slowing down our engineering velocity.

Pavan Kumar Lekkala
Pavan Kumar Lekkala
SRE Lead, HugoHub

We are excited to leverage Cloudanix's comprehensive multi-cloud DevSecOps solution to secure our production workloads on AWS. Cloudanix has demonstrated that it can solve many challenges that DevSecOps teams face while continually adding new features such as SOC2 compliance and drift detection.

Satish Mohan
Satish Mohan
Co-founder & CTO, Airgap Networks

Managing third-party partner access was once a major concern for our security posture. With Cloudanix JIT Cloud, we've effectively achieved zero third-party risk. We can now grant access confidently, knowing that it is temporary, audited, and automatically revoked, resulting in a 100% reduction in our privileged access exposure.

Okesh Badhiye
Okesh Badhiye
Head of Technical Engineering, Finfinity

The snooze feature and responsible alerts have helped us save time and prioritize what to tackle first.

Satish Mohan
Satish Mohan
Co-founder & CTO, Airgap Networks

Implementing Cloudanix JIT internally allowed us to practice what we preach. By eliminating permanent access to our own clouds and databases, we've neutralized the risk of standing privileges, ensuring our own 'keys to the kingdom' are never left exposed.

Girish Manghnani
Girish Manghnani
Managing Partner, Tech Inspira

The problem with permissions is a lot of times, the gaps are left open due to oversights from inside the organization itself. With Cloudanix's CIEM, we get a complete view of user permissions and access. This enables us to update the permissions, reducing the attack surface.

Nilesh Pethani
Nilesh Pethani
Application Architect, iMocha

In the world of Fintech, trust is our currency. Cloudanix provided the frictionless visibility we needed to secure our EKS workloads across AWS, ensuring we stay audit-ready for SOC2 and GDPR without slowing down our engineering velocity.

Amol Naik
Amol Naik
Head of Security & Infrastructure, HugoHub

Cloudanix delivered value within 5 minutes of onboarding. Continuous monitoring, timely detection, and excellent documentation helped us attain a great cloud security posture.

Divyanshu Shukla
Senior DevSecOps, Meesho

Technology strategies and business strategies are in a state of constant change which includes centralization and decentralization of responsibilities. Regardless of strategic shift, we still have intellectual property to protect. Cloudanix are critical partners for us in our public cloud security posture across our three cloud providers.

Jerry Locke
Jerry Locke
Senior Director Global Solutions Engineering, Eversana

Cloudanix has been amazing. They opened up a common Slack channel with us — and it feels like we are talking to our own team and getting things done with Cloud security. The support team is always available, friendly, helpful, and ready to go out of their way.

Satish Mohan
Satish Mohan
CTO, Airgap Networks

Beyond just access management, Cloudanix CSPM has given us a unified view of our AWS environment. The real-time alerting and anomaly detection allow us to prevent any untoward activity before it happens, which is critical for a marketplace connecting 50+ financial institutions.

Okesh Badhiye
Okesh Badhiye
Head of Technical Engineering, Finfinity

For a Fintech company, data is our most valuable — and most sensitive — asset. Cloudanix DAM hasn't just improved our visibility; it has given us control. The ability to mask data and prevent unauthorized queries in real-time is a game-changer for our compliance and customer trust.

Jiten Gala
Jiten Gala
President Engineering and Product, Kapittx

Our clients, especially in the Middle East financial sector, demand absolute accountability. Cloudanix JIT Cloud has been a competitive differentiator for us, allowing us to provide secure, governed access to customer accounts that meet their strictest audit and compliance requirements.

Girish Manghnani
Girish Manghnani
Managing Partner, Tech Inspira

Cloudanix is always on my team's lips because of its exceptional support. Be it a small or big query, Cloudanix has gone above and beyond to resolve them. This one's a keeper for us.

Sujit Karpe
Sujit Karpe
CTO, iMocha

For a long-lasting partnership, great support goes a long way. Cloudanix has delivered exceptional support whenever required. Their edge is their team is always ready to go beyond to solve any issues that we have. This speaks volumes about the culture at Cloudanix.

Akash Maheshwari
Akash Maheshwari
Co-founder, MoveInSync

Beyond the technology, Cloudanix feels like an extension of our own team. Their willingness to stand up a dedicated Middle East tenant for us and provide exceptional support at a sensible price makes them a long-term partner for Hugosave.

Surya Tamada
Surya Tamada
CTO, HugoHub

The real-time notifications that Cloudanix provides are a real lifesaver. Their adaptive notifications ensure that my team stays productive and doesn't get interrupted all the time.

Digvijay Singh
Staff Security Engineer, Meesho

The whole point in technological evolution is to help improve the world we live in. We must protect that and to do so requires an effective and efficient security strategy. The Cloudanix team helped make our public cloud security posture management strategy a reality. The symbiotic relationship we have allows for a continuous feedback loop which is how business should operate.

Larry Wheat
Larry Wheat
Staff Solutions Engineer, Eversana

Ready to see your graph?

Connect a cloud account in under 30 minutes. See every finding rooted in identity, asset, and blast radius — with a fix path attached.

Book a Demo