Container Security: Image Scanning and Vulnerability Risks

Implement comprehensive container security: from scanning images for vulnerabilities to runtime security monitoring and secrets protection.

published: reading time: 26 min read author: Geek Workbench updated: November 8, 2026
Quick Summary

Container security spans build, admission, and runtime: scan images and SBOMs, verify trusted signatures, limit workload privileges, and monitor behavior covered by runtime rules. This guide compares Trivy and Grype, explains Kubernetes controls such as seccomp and Pod Security Admission, and covers secrets, network policy, and vulnerability exceptions. Use it to build layered checks while keeping scanner and sensor limits visible.

Container Security: Image Scanning and Vulnerability Risks

Introduction

An image packages an application with its runtime dependencies, so a vulnerable library or unsafe default can follow it into every environment where it runs. Securing containers means checking what gets built and what the workload can do after deployment.

This guide covers image scanning and inventories, least-privilege runtime settings, and monitoring for unexpected behavior. These controls reduce risk, but they still need to work alongside host, registry, and orchestrator protections.

When to Use / When NOT to Use

Use container-specific controls when you build, publish, or operate container images, especially when several teams contribute images, workloads handle sensitive data, or a deployment needs elevated privileges. They help teams find vulnerable packages before release and limit what a compromised workload can reach at runtime.

For software that does not run in containers, apply the equivalent application and host controls instead. A small local experiment can start with a trusted minimal image and a non-root user; add image policies and runtime monitoring as the workload moves into shared or production environments.

Image Scanning with Trivy and Grype

Scan every image before it touches your cluster. Not sometimes. Not in staging only. Every image, every push, in your CI pipeline.

Trivy is the default choice for most teams. It is fast, has a large vulnerability database, and integrates with most CI systems.

# Install Trivy
brew install trivy

# Scan an image
trivy image myregistry/myapp:latest

# Scan in CI with exit code on high vulnerabilities
trivy image --exit-code 1 --severity HIGH,CRITICAL myregistry/myapp:latest

Grype is another option, particularly if you want to scan SBOMs (Software Bills of Materials) or need a different database backend.

# Install Grype
brew install grype

# Scan with SBOM input
grype sbom:./sbom.json

# JSON output for automation
grype image myregistry/myapp:latest -o json > results.json

Both tools pull from multiple vulnerability databases including the Ubuntu, Debian, and Alpine security feeds, plus the Python Package Index and npm registry.

SBOM Generation and Vulnerability Tracking

An SBOM is a formal record of the packages and dependencies in your software. Think of it as an ingredient list for your container image.

Generate SBOMs at build time:

# Generate SBOM with Syft
syft myregistry/myapp:latest -o spdx-json > sbom.spdx.json

# Or in Dockerfile build with buildpacks
pack build --builder heroku/buildpacks:20 myregistry/myapp:latest

SBOMs serve two purposes. First, when a new vulnerability drops (like Log4Shell), you can query your SBOM database to find every image affected in minutes, not hours. Second, SBOMs give you audit trails for compliance.

Store SBOMs alongside your images in a registry that supports it, or in a separate artifact storage.

Runtime Security with Falco

Image scanning can find known vulnerable packages before deployment. Falco can alert on runtime behavior that matches configured rules, including activity specific to your workloads. Its coverage depends on the rules, runtime, and host visibility you configure.

Falco works by monitoring system calls. You define rules for behavior you consider suspicious:

# falco_rules.yaml
- rule: Detect shell in container
  desc: A shell was spawned inside a container
  condition: >
    container and
    proc.name = bash
  output: >
    Shell spawned in container
    (user=%user.name container=%container.name
    image=%container.image.repository)
  priority: WARNING

- rule: Detect crypto mining
  desc: Detect execution of known crypto miner
  condition: >
    spawned_process and
    proc.name in (cpuminer, nanominer, ethminer)
  output: >
    Crypto miner detected
    (user=%user.name command=%proc.cmdline)
  priority: CRITICAL

Falco is commonly deployed as a DaemonSet so it can observe activity on cluster nodes. It generates events for behavior covered by its rules; it cannot see every suspicious action or guarantee that an attack will be detected.

Non-Root Users and Read-Only Root Filesystems

Design your containers to run as non-root by default. This is harder than it sounds because many official images run as root internally.

# Create a non-root user in your Dockerfile
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser

# If you must run as root, switch before running the app
USER root
RUN some-privileged-operation
USER appuser

Pair non-root users with read-only filesystems. If an attacker compromises your container, they cannot write to the filesystem.

# Kubernetes pod spec
securityContext:
  readOnlyRootFilesystem: true
  runAsNonRoot: true
  runAsUser: 10000

You will need to identify which directories need write access and mount them as volumes.

Seccomp and AppArmor Profiles

Seccomp (secure computing mode) restricts the system calls a container can make. By default, containers can make hundreds of system calls. Seccomp lets you whittle that down to the handful your application actually needs.

In Kubernetes, request the runtime’s default seccomp profile and AppArmor profile through a pod or container security context. The following fragment belongs under the pod’s spec.securityContext on a supported Linux cluster:

seccompProfile:
  type: RuntimeDefault
appArmorProfile:
  type: RuntimeDefault

For Kubernetes versions before 1.30, AppArmor was configured through annotations; use the API supported by your cluster version. Docker provides a default seccomp profile. Kubernetes uses the runtime default only when the kubelet’s seccompDefault setting is enabled; otherwise an unspecified profile may be unconfined. Set RuntimeDefault explicitly when that is the intended policy, and test the workload before enforcement.

Supply Chain Security

A compromised upstream dependency can reach many downstream images. Build provenance, reviewable dependencies, and signed artifacts help teams identify what they deploy and who produced it.

flowchart LR
    A[Image Build] --> B[Trivy Scan]
    B --> C{ Vulnerabilities found? }
    C -->|High/Critical| D[Block Deploy]
    C -->|None/Low| E[Generate SBOM]
    E --> F[Cosign Sign]
    F --> G[Push to Registry]
    G --> H[Kyverno Policy Check]
    H --> I{ Signature Valid? }
    I -->|No| J[Reject Pod]
    I -->|Yes| K[Deploy to Cluster]
    K --> L[Falco Runtime Monitor]
    L --> M[Alert on Anomaly]

Pin base images to specific digests, not tags. Tags are mutable; a node:18-alpine today is not the same as node:18-alpine in six months.

# Replace the placeholder with the complete digest of the reviewed image.
FROM node:18-alpine@sha256:<full-reviewed-image-digest> AS builder

Use image signing to record which trusted build identity produced an image. Cosign, part of Sigstore, can sign image digests; an admission controller such as Kyverno can verify the signature before allowing a workload to run.

# Sign an image
cosign sign --key cosign.key myregistry/myapp@sha256:<image-digest>

# Use a Kyverno policy with a verifyImages rule configured for trusted identities.
kubectl apply -f kyverno-verify-images-policy.yaml

Production Failure Scenarios

Failure Impact Mitigation
Trivy blocking deployment for critical CVE with no immediate patch Build pipeline halts, deployment delayed Establish a vulnerability exception process with risk acceptance sign-off, prioritize CVEs by exploitability (EPSS score) over severity alone
Falco false positives causing alert fatigue Security team ignores alerts, real threats missed Tune Falco rules to your environment, suppress known-false positives, review rule effectiveness quarterly
Container escape from a root workload Depending on runtime isolation and capabilities, an escape may expose host resources or affect other workloads Run as non-root, drop unnecessary capabilities, and enforce a restricted workload policy where compatible
Supply chain compromise via malicious base image Backdoored image deployed to production Pin base images to digests, use Cosign signature verification, scan all third-party images in CI
:latest tag image mutation causing inconsistency Different nodes run different image versions, unpredictable behavior Always tag builds with commit SHA, never pull :latest in production

Trade-Off Table

Scenario Trivy Grype Notes
Vulnerability database size Large Large Both cover major OS and language package feeds
SBOM workflow Can generate SPDX/CycloneDX Scans images or SBOMs; pair with Syft for generation Trivy can generate SBOMs directly; Grype is commonly paired with Syft
CI integration Native Native Both can fail CI when configured with explicit exit thresholds
JSON output for automation Yes Yes Both produce structured output
Performance Measure Measure Results depend on image contents, database state, and configuration
Scenario Falco (runtime) Prevention-only Notes
Detects novel behavior May alert on configured anomalies No Detection is not guaranteed; maintain rule and response coverage
Performance overhead Workload-dependent None Measure impact under representative workloads
Requires tuning Yes No Falco needs rule customization per environment
Audit evidence Can record runtime events Limited Evidence value depends on retention, access controls, and policy
Context When signature enforcement helps Operational consideration
Multi-team registry Use trusted identities to control which images workloads can run Admission verification does not prevent someone from pushing an image to the registry
Single-maintainer builds Signing still records image provenance Choose a workflow the maintainer can protect and recover
Regulated environments Map signing evidence to the applicable policy or contract Requirements vary; check the actual obligations instead of assuming every framework requires it
Scenario Rootless containers Privileged containers Notes
Host impact Lower when user namespaces are configured Greater potential host access Rootless mode changes impact for some escapes; it does not eliminate container risk
Compatibility Workload-dependent May be required by narrow cases Test needed capabilities and permissions before choosing a mode
Performance Measure per workload Measure per workload Performance alone does not justify broad privileges

Observability Checklist

Monitor CVE counts per image as a metric in your CI pipeline. A new critical finding for an unchanged image may reflect an advisory database update or newly identified package. Compare findings between scans and alert on new critical issues so an owner can review the affected dependency.

Review Falco alert volume and context by rule. Frequent events may indicate noisy rules or normal workload behavior; tune only after confirming what the events represent, and retain coverage for behaviors that matter to your threat model.

Track container restart rates. Containers that restart every few minutes are either crashing or being evicted repeatedly. Both are worth investigating.

  • Record image digest, scan timestamp, and findings by severity for every release. Alert on new critical findings or a sudden increase in high-severity findings.
  • Track signed-image admission denials and policy violations by namespace. A rise can mean a broken release pipeline or an attempted policy bypass.
  • Review Falco alerts by rule and workload. Page on high-confidence behaviors such as unexpected shells or writes to sensitive paths; route noisy findings for tuning.
  • Watch restart and crash-loop rates alongside container privilege settings. Investigate sudden changes rather than treating a restart count as proof of compromise.
  • Keep an inventory of deployed image digests and compare it with approved build artifacts so drift is visible.

Key commands:

# Trivy scan with JSON output for metrics extraction
trivy image --exit-code 1 --severity HIGH,CRITICAL --format json myregistry/myapp:latest > scan-results.json

# Count CVEs by severity
jq '[.Results[].Vulnerabilities[]?.Severity] | group_by(.) | map({severity: .[0], count: length})' scan-results.json

# Falco alert volume by rule in the last hour
kubectl logs -l app=falco -n falco --since=1h | jq -r '.rule' | sort | uniq -c | sort -rn

# List images with most critical vulnerabilities across your cluster
kubectl get pods -A -o jsonpath='{range .items[*]}{.spec.containers[*].image}{"\n"}' | tr ' ' '\n' | sort -u | while read img; do echo "$img: $(trivy image --quiet --severity CRITICAL "$img" 2>/dev/null | grep -c CRITICAL || echo 0)"; done | sort -t: -k2 -rn | head -10

Security and Compliance Notes

Treat image provenance, workload privilege, and cluster policy as separate checks. Pin images to digests, verify signatures from trusted build identities at admission, and enforce a restricted pod baseline where workloads allow it. Run as non-root, disable privilege escalation, and mount the root filesystem read-only when the application supports it. Remove capabilities the workload does not need; dropping all capabilities can break legitimate operations, so test the chosen set against startup, health checks, and expected network or filesystem behavior. Avoid privileged mode and broad hostPath mounts; grant a documented exception only to a workload that has a clear need.

Never bake credentials into image layers. Whether runtime environment variables are acceptable depends on the platform and threat model: they can appear in diagnostics, process metadata, or application logs, while mounted secret files also need access controls and rotation. Prefer workload identity or a secret manager where available; otherwise scope access, limit lifetime, and test the delivery and rotation path. Network policies should allow only the communication the service needs.

For audits, keep records that connect the deployed digest to its build, scan results, signature verification, policy decision, and exception owner. Compliance frameworks differ, so map these controls to the requirements that apply to your organization rather than treating a scanner report or a specific tool as proof of compliance. Record compensating controls and review dates when a workload cannot meet the baseline.

Common Pitfalls / Anti-Patterns

Running containers as root. Many images default to root inside the container. If an escape occurs, the impact depends on runtime isolation, user namespaces, capabilities, and host configuration. Prefer a non-root user and remove capabilities the workload does not need.

Not scanning images. Scans can surface known package vulnerabilities, but teams need a triage policy. Consider severity alongside exploitability, exposure, available fixes, and compensating controls; record a time-limited exception when a release must proceed.

Using the :latest tag. Tags can move, so the same reference may resolve to different image content later. Use a reviewed digest for production deployment and update it through a reviewed change. Test the new image before promotion.

Treating signatures as a registry lock. Cosign records a trusted signature, while an admission policy decides whether a workload may run the image. Configure both and test the policy; signing alone does not block registry pushes or deployment.

Expecting a runtime sensor to catch every attack. Image scanners and runtime rules have different blind spots. Falco may alert on configured behaviors, but its coverage depends on rules, sensor health, and response.

Container Security Control Matrix

Layer Tool Preventative vs Detective CI/CD vs Runtime
Image scanning Trivy, Grype, Snyk Preventative CI/CD
Sig verification Cosign, Notary Preventative CI/CD + Registry
Runtime monitoring Falco, Sysdig Detective Runtime
Policy enforcement OPA Gatekeeper, Kyverno Preventative Admission control
User namespace remapping –userns-remap Preventative Daemon config
Syscall filtering seccomp, AppArmor, SELinux Preventative Daemon config
Network policies K8s NetworkPolicy Preventative Runtime

Quick Recap Checklist

  • Scan every image in CI and review findings before deployment.
  • Pin images to digests and verify signatures against trusted identities.
  • Run containers with the least privilege the workload needs.
  • Use runtime monitoring to investigate behavior scanners cannot see.

Interview Questions

1. A container is running as root in a production pod. What are the risks and how do you reduce them?

Root inside a container does not automatically mean host root. An escape's impact depends on the runtime, user namespaces, capabilities, and host settings. Run as a non-root UID when the app supports it, set allowPrivilegeEscalation: false, and grant only the capabilities the process needs. Kubernetes' Restricted Pod Security Standard requires dropping all capabilities, with a narrow allowance for NET_BIND_SERVICE; verify that policy against the workload before enforcing it.

2. You discover a critical CVE in a base image used across 200 microservices. Walk through your response.

First, stop the bleeding: block the vulnerable image version in your CI/CD admission control (OPA Gatekeeper or Kyverno). Identify all affected services via your image registry tags and deployment inventory. Prioritize by exposure (internet-facing vs internal) and data sensitivity. Build and push fixed images for the highest-priority services, test, and deploy. For lower-priority services, schedule into sprint planning. Set up automatic vulnerability scanning on new image pushes to catch this earlier. Consider a "golden image" strategy where security hardens a base image centrally.

3. How do you prevent a compromised CI/CD pipeline from deploying malicious images?

Use image signing and verification: sign images with Cosign or Notary during the build pipeline, then verify signatures at admission time using a policy controller (Kyverno or OPA Gatekeeper). Store signing keys in a KMS (AWS KMS, Google Cloud KMS, HashiCorp Vault). Enable admission control to reject unsigned images. Use short-lived tokens for CI/CD authentication rather than long-lived credentials. Audit all image pull events. Use a software bill of materials (SBOM) to track what went into each image.

4. What is the difference between seccomp, AppArmor, and SELinux in the context of container security?

Seccomp restricts syscalls a container can make at the kernel level — the most granular control but requires knowing which syscalls an application needs. AppArmor works at the application level, restricting capabilities and file access paths — easier to use for known application profiles. SELinux works at the system level, labeling files and processes — most powerful but complex to configure. In practice, request the runtime default through securityContext.seccompProfile and configure AppArmor with the appArmorProfile field on Kubernetes 1.30 or later. Older Kubernetes versions use the AppArmor annotation supported by that release. SELinux is commonly enforced at the host level.

5. How do you detect that a container has been compromised at runtime?

Runtime detection tools like Falco monitor syscall behavior and flag anomalous activity: a shell spawning inside a container, unexpected network connections, writing to sensitive paths like /etc/ or /root/. Sysdig captures system calls for deeper analysis. Network monitoring detects exfiltration attempts via unusual outbound traffic. Integrate these with your SIEM or alerting system. Also monitor container restart counts, unexpected process trees (kubectl top pods showing unusual CPU), and node-level indicators like new SSH keys in /root/.ssh/.

6. What are the key differences between Trivy and Grype for vulnerability scanning, and when would you choose one over the other?

Both tools can scan container images and SBOM inputs. Trivy can also generate SPDX or CycloneDX SBOMs directly, while Grype is commonly paired with Syft when a pipeline needs SBOM generation. Compare supported package types, integrations, output formats, and policy thresholds against your own images before choosing.

7. Explain how Cosign image signing works and how you would enforce signature verification in a Kubernetes cluster.

Cosign generates a key pair, signs your container image digest, and stores the signature as an OCI artifact in your registry alongside the image. To enforce verification in Kubernetes, deploy Kyverno or OPA Gatekeeper as an admission controller. Create a policy that queries the registry for a valid Cosign signature before allowing the pod to start. If the image is not signed or the signature is invalid, the admission controller rejects the pod. Store the Cosign private key in a KMS (AWS KMS, Google Cloud KMS, HashiCorp Vault) — never in the pipeline itself. Rotation involves re-signing all images with the new key and updating the policy.

8. A container needs to write to the filesystem at runtime but you also want a read-only root filesystem. How do you handle this?

Identify the specific paths the application needs to write to at runtime. Common candidates are /tmp, /var/log, and /run. Create emptyDir volumes mount at those paths in your pod spec. Set readOnlyRootFilesystem: true globally, then selectively mount writable volumes to the specific locations the application requires. For log directories, mount an emptyDir or a mounted NFS share. This approach gives you the security benefit of a read-only root while allowing legitimate writes where needed. You can also use a tmpfs mount for temporary files.

9. How do Kubernetes Pod Security Standards (PSS) and Pod Security Admissions (PSA) work, and how do they compare to Pod Security Policies?

Pod Security Standards define the Privileged, Baseline, and Restricted policy levels. The built-in Pod Security Admission controller can enforce a selected level for a namespace, for example with the pod-security.kubernetes.io/enforce: restricted label. PodSecurityPolicy was deprecated in Kubernetes 1.21 and removed in 1.25; it was a built-in admission controller, not a required mutating webhook. Use Pod Security Admission for the standard profiles or a maintained policy engine when a workload needs rules beyond those profiles.

10. How do you choose and test Linux capabilities for a container?

Capabilities split some root privileges into smaller permissions. Start from the platform's required baseline, then remove permissions the process does not use. A Kubernetes Restricted policy expects drop: ["ALL"] and permits adding back NET_BIND_SERVICE when needed. Dropping all capabilities can still break applications that bind low ports, inspect network state, or use a platform-specific operation. Test startup, readiness, representative requests, shutdown, and maintenance commands in staging; inspect effective capabilities when diagnosing permission errors.

securityContext:
  capabilities:
    drop: ["ALL"]
    # Add only when the app must bind a port below 1024:
    # add: ["NET_BIND_SERVICE"]
11. How do you handle secrets management for containers — specifically, how do you avoid putting secrets in container images or environment variables?

Do not bake secrets into an image: deleting a secret in a later layer does not remove it from earlier image layers. Runtime environment variables do not automatically become image layers, but they may be visible through process inspection, diagnostics, or application logs. Mounted files have their own permission, sharing, and rotation risks. Prefer workload identity or a secret manager where the platform supports it; otherwise scope access and use short-lived credentials when possible.

12. Walk through the steps you would take to perform container forensics after detecting a potential compromise.

First, isolate the affected pod — prevent it from scheduling new work while you investigate. Capture the running container state: docker inspect for the container config, docker diff to see filesystem changes from the image, and docker logs for stdout/stderr. Extract the container's process tree with docker top and network connections with docker exec netstat or similar. Take a snapshot of the container's memory with docker checkpoint if your runtime supports it. Pull the image and compare it to the expected image digest. Preserve logs and audit trails before letting the pod restart or scaling it out.

13. How do you set up Kubernetes network policies to enforce container-to-container traffic and what are common mistakes in their configuration?

Network policies in Kubernetes are namespace-scoped and act as a firewall for egress and ingress traffic per pod. Label your namespaces and pods, then create a NetworkPolicy that selectors the appropriate pods. For a frontend-backend setup: the frontend policy allows ingress from the ingress controller only, the backend policy allows ingress from the frontend only. Common mistakes: forgetting that network policies are additive within a namespace (a pod with no policy is fully accessible), not accounting for DNS resolution (pods need to communicate with kube-system for DNS), and applying policies only to named namespaces without understanding that pods in unlabeled namespaces can still reach your services.

14. What is an SBOM, why does it matter for container security, and how do you generate and use one in a CI/CD pipeline?

An SBOM (Software Bill of Materials) is a structured inventory of every package and dependency in your container image — the equivalent of an ingredient list. It matters because when a new vulnerability drops (like Log4Shell), you query your SBOM database to identify every affected image in minutes rather than scanning each one individually. To generate one: use Syft to scan your image and produce an SPDX or CycloneDX SBOM. Store the SBOM alongside the image in your registry or in a separate artifact store. In CI/CD, generate the SBOM after building the image, store it as a build artifact, and integrate it with your vulnerability scanner so Grype or Trivy can correlate CVE data with your exact package versions.

15. How does Falco rule tuning work in practice, and how do you balance catching real threats against alert fatigue?

Start with the default Falco rule set and run in audit mode — Falco logs warnings but does not block. Collect a week of alerts and identify which rules fire hundreds of times per day. Those rules are noise in your environment. Suppress them by creating exceptions in falco config. Then identify which alerts represent genuine security signals by correlating with known incidents. Keep those rules. Review quarterly — rule effectiveness changes as your workload changes. The goal: security engineers should be able to investigate every Falco alert that fires in a day. If they cannot, you have too much noise and will miss real incidents.

16. What are the security implications of using hostPath volumes in Kubernetes and what alternatives should you use instead?

hostPath mounts expose a selected node path inside a pod, so a writable or broad mount can expose host data or files. Prefer ConfigMaps for configuration, secret providers for credentials, emptyDir for temporary files, and PersistentVolumeClaims for persistent application data. If a workload truly needs hostPath, mount only the required path, make it read-only where possible, and use RBAC plus an admission policy to limit which workloads can request it. Pod Security Standards do not grant per-service-account exceptions for arbitrary host paths.

17. How do you ensure that base images pulled from public registries are not compromised before using them in your builds?

Never pull by tag alone — tag mutability means node:18-alpine today is not the same image in six months. Pin to a full reviewed digest in your Dockerfile; replace any example placeholder with the digest from your approved registry artifact. Scan every image in CI before it is used, even if it comes from a trusted registry like Docker Hub. Use a VEX (Vulnerability Exploitability eXchange) document to communicate which CVEs in your dependencies are not exploitable in your context. For critical workloads, maintain a hardened "golden image" base that your security team audits and signs with Cosign. Pull from official sources only and verify the registry's image signature when available.

18. Explain the difference between vulnerability scanning at build time versus runtime security monitoring. When would you rely on one versus the other?

Build-time scanners identify known package vulnerabilities in an image or SBOM before release. Runtime monitors such as Falco can alert on selected behavior after deployment, including activity that a vulnerability scanner cannot assess. Neither control detects every attack: scanners depend on package and advisory data, while runtime coverage depends on sensor health, rules, and response. Use both as complementary controls and maintain a response path for findings from either one.

19. What steps do you take to ensure your container image layers do not expose sensitive information or increase the attack surface unnecessarily?

Layer ordering matters: put instructions that change most frequently at the end of the Dockerfile so that cache invalidation does not rebuild sensitive layers. Never put secrets in RUN commands — they appear in the layer history. Use multi-stage builds so the final image contains only the runtime artifacts, not the build toolchain (which may include source code or build secrets). Set appropriate file permissions in the Dockerfile (chmod only what is needed). Remove package manager caches, package lists, and temporary files in the same layer that installs them. Validate that the final image does not contain shell, package managers, or debugging tools unless explicitly needed at runtime.

20. How would you integrate container security scanning into a CI/CD pipeline, and what do you do when a build fails due to a critical vulnerability?

Configure the scanner's exit behavior and severity threshold in CI, then run it against the built image before release. When a critical finding blocks a build, first update the package or base image and rebuild. If no fix is available and release is necessary, document the affected workload, exploitability evidence, owner, compensating controls, and review date in a time-limited exception. Runtime monitoring may help detect some exploitation attempts, but it does not make a vulnerable image safe.

Further Reading

Conclusion

Key Takeaways

  • Image scanning identifies known package issues; runtime rules may flag selected workload behavior
  • Pin base images to digests, not tags, to prevent supply chain drift
  • Run containers as non-root with read-only filesystems to limit container escape blast radius
  • Admission verification can reject images that lack a signature from a trusted identity
  • Falco can add runtime visibility for behaviors covered by its rules

Container Security Checklist

# 1. Scan every image in CI, block on HIGH/CRITICAL
trivy image --exit-code 1 --severity HIGH,CRITICAL myregistry/myapp:$GIT_COMMIT

# 2. Pin base images to digest
FROM node:18-alpine@sha256:<full-reviewed-image-digest> AS builder

# 3. Build as non-root
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser

# 4. Enforce read-only root filesystem
securityContext:
  readOnlyRootFilesystem: true

# 5. Sign images with Cosign
cosign sign --key cosign.key myregistry/myapp:$GIT_COMMIT

# 6. Verify signatures in Kubernetes with Kyverno
kubectl apply -f kyverno-policy-require-signed-images.yaml

# 7. Deploy Falco as DaemonSet
helm install falco falcosecurity/falco -n falco --create-namespace

For more on securing Kubernetes workloads, see Network Security. For secrets handling, see Secrets Management.

Category

Related Posts

DevOps & Cloud Infrastructure Roadmap: From Containers to Cloud-Native Deployments

Master DevOps practices with this comprehensive learning path covering Docker, Kubernetes, CI/CD pipelines, infrastructure as code, and cloud-native deployment strategies.

#devops #cloud #kubernetes

JVM in Containers: Cgroup Memory Limits and Heap Sizing

A guide to how the JVM detects container memory limits, configures heap accordingly, and avoids pitfalls when running Java in Docker and Kubernetes.

#java #jvm #containers

Container Images: Building, Optimizing, and Distributing

Learn how Docker container images work, layer caching strategies, image optimization techniques, and how to publish your own images to container registries.

#docker #containers #devops