container-image-hardening
Container Image Hardening
Purpose
A container image built from a full general-purpose base image (e.g. a default Ubuntu or Debian image with a shell, package manager, and dozens of unrelated utilities) running as root gives an attacker who compromises the application inside it a much larger toolkit and a much easier path to container breakout or lateral movement than a minimal, non-root image with no shell and only the application's actual runtime dependencies. Container image hardening is about shrinking that attack surface at build time: using multi-stage builds so build tooling never ships in the final image, choosing minimal or distroless base images, running as a non-root user, making the root filesystem read-only, dropping unnecessary Linux capabilities, and pinning base images by digest so "the same image" can't silently change out from under you. None of this replaces vulnerability scanning of what is in the image — it reduces what's there to scan and what's exploitable if a vulnerability is found.