Container Security
Comprehensive security for Docker containers and Kubernetes clusters - from build time through deployment to runtime protection.

What is Container Security?
Container Security encompasses all practices, tools, and processes for securing containerized applications from build time through deployment to runtime. Containers share the host system's kernel, which introduces new security challenges compared to traditional virtual machines. Effective container security requires a multi-layered approach covering image scanning, runtime protection, network isolation, secrets management, and compliance enforcement.
Why is Container Security Critical?
Containers have transformed how we develop and deploy applications, but they have also introduced new security risks:
- Shared kernel: All containers on a host share the same OS kernel - a kernel exploit can compromise the entire host
- Image vulnerabilities: according to the Sysdig 2023 Cloud-Native Security and Usage Report, 87% of container images have high or critical vulnerabilities
- Misconfigurations: Privileged containers, mounted Docker socket, exposed APIs
- Supply chain risks: Untrusted base images, malicious layers, backdoored dependencies
- Runtime threats: Container breakout, lateral movement, crypto mining
- Secrets exposure: Hardcoded credentials, env variables, mounted secrets
- Network attacks: Pod-to-pod lateral movement without network policies
Notable Container Security Incidents
- Tesla Kubernetes cryptojacking (disclosed 2018): A Kubernetes console without a password exposed AWS credentials, and attackers mined Monero on the infrastructure (RedLock findings)
- Docker Hub malicious images (2018): 17 backdoored images from the docker123321 account contained cryptominers and reverse shells; Docker removed them on May 10, 2018 (BleepingComputer)
- RunC vulnerability (CVE-2019-5736): Container breakout: overwriting the host runc binary and gaining root access (runc through 1.0-rc6, Docker before 18.09.2)
- Kinsing malware: Abuses publicly exposed Docker APIs without authentication, runs a cryptominer and spreads over SSH to other hosts and containers (Aqua Security)
Container Security Layers
Defense in Depth Approach
1. Build Time Security
Security during the image build process
- Base image selection (minimal, trusted sources)
- Dockerfile best practices (non-root user, no secrets)
- Image scanning for CVEs (Trivy, Snyk, Clair)
- Multi-stage builds for a smaller attack surface
- Image signing and verification (Cosign, Notation); Docker Content Trust (Notary v1) is retired on December 8, 2026
2. Registry Security
Securing the container registry
- Private registries with authentication
- Image vulnerability scanning in the registry
- Access control (RBAC, IAM)
- Image retention policies
- Webhook notifications for new vulnerabilities
3. Orchestration Security (Kubernetes)
Securing the Kubernetes cluster
- Pod Security Standards (Restricted, Baseline)
- Network Policies (CNI-based isolation)
- RBAC for users and service accounts
- Admission Controllers (OPA, Kyverno)
- Secrets management (Vault, External Secrets)
4. Runtime Security
Monitoring and protection of running containers
- Runtime behavior monitoring (Falco, Tetragon)
- Anomaly detection
- Process/file/network monitoring
- Intrusion prevention
- Audit logging
5. Host Security
Securing the underlying infrastructure
- Minimal host OS (COS, Bottlerocket)
- Kernel hardening (AppArmor, SELinux)
- Host patching and updates
- CIS Benchmarks compliance
- Node isolation
Docker Security Best Practices
Secure Dockerfile
Docker Compose Security
Image Scanning Tools
Trivy
Open-source scanner by Aqua Security for container images, filesystems, git repos, and Kubernetes.
- Detects CVEs in OS packages and application dependencies
- Supports Docker, containerd, Kubernetes
- Fast (seconds) with offline mode
- IaC scanning (Terraform, CloudFormation)
- Secret detection
- SBOM generation
Clair
Static analysis tool for vulnerabilities in container images, developed as part of the Quay project.
- Layer-by-layer analysis
- Multiple vulnerability databases
- API-first design
- Integration with Quay registry
Snyk Container
Developer-first container security with fix recommendations.
- Base image recommendations
- Prioritized fix guidance
- CI/CD integration
- Kubernetes deployment scanning
AWS ECR Scanning
Native image scanning in Amazon ECR registries.
- Basic scanning (AWS native technology, OS packages)
- Enhanced scanning (Amazon Inspector, OS and language packages)
- Scan on push, plus continuous scanning with Enhanced
- EventBridge notifications
Practical Example: Trivy in CI/CD
The actions in this example are pinned to a full commit SHA. In March 2026, attackers force-pushed 76 of 77 tags of
aquasecurity/trivy-action to code that stole CI/CD secrets (CVE-2026-33634,
Aqua Security). A mutable tag or @master does not protect against that.
Kubernetes Security
Pod Security Standards
Kubernetes defines three levels of Pod Security Standards, enforced by the built-in Pod Security Admission. PodSecurityPolicy was removed in version 1.25:
Network Policies
Items in a from/to list are combined with OR; selectors within one item apply together (AND).
Select namespaces by the kubernetes.io/metadata.name label, which Kubernetes sets automatically
(Kubernetes: Network Policies).
Runtime Security
Falco
Runtime security tool using eBPF for syscall monitoring and anomaly detection. A CNCF graduated project since February 2024.
- Detects abnormal behavior (shell spawn, file access)
- Custom rules (Falco rules syntax)
- Kubernetes-aware
- Real-time alerting
- Integration with SIEM
Tetragon
eBPF-based security observability and runtime enforcement by Cilium.
- Process execution monitoring
- File access tracking
- Network connections
- Syscall filtering
- Policy enforcement
Falco Rules Example
Container Security Best Practices - Summary
Build Time
- Use minimal base images (alpine, distroless, scratch)
- Specific version tags (not latest)
- Multi-stage builds for smaller images
- Scan images before pushing to registry (Trivy, Snyk)
- Non-root user
- No secrets in images or Dockerfile
- Sign images (Cosign, Notation)
Kubernetes Deployment
- Pod Security Standards (Restricted for production)
- Network Policies (default deny all)
- Resource limits (CPU, memory)
- RBAC (least privilege)
- Secrets from external store (Vault, AWS Secrets Manager)
- Admission controllers (OPA, Kyverno)
- Service mesh for mTLS (Istio, Linkerd)
Runtime
- Runtime monitoring (Falco, Tetragon)
- Anomaly detection and alerting
- Audit logging
- Incident response playbooks
- Regular security audits
What NOT to Do
- Use the latest tag in production
- Run containers as root
- Mount Docker socket into a container
- Privileged containers without justification
- Hardcoded secrets in images
- No network policies
- Disable security features for "faster debugging"
- Ignore scan results
Sources
- Sysdig: Sysdig 2023 Cloud-Native Security and Usage Report (press release) (February 2023)
- BleepingComputer: Tesla Internal Servers Infected With Cryptocurrency Miner (February 2018)
- BleepingComputer: 17 Backdoored Docker Images Removed From Docker Hub (June 2018)
- NVD: CVE-2019-5736 (June 2026)
- Aqua Security: Threat Alert: Kinsing Malware Attacks Targeting Container Environments (August 2023)
- Aqua Security: Trivy Supply Chain Attack: What You Need to Know (April 2026)
- NVD: CVE-2026-33634 (March 2026)
- Docker Docs: Content trust in Docker (June 2026)
- Docker Docs: Version and name top-level elements (July 2025)
- Kubernetes: Pod Security Standards (August 2026)
- Kubernetes: Network Policies (April 2026)