intermediateContainer Security: Non-Root, Secrets, Image Scanning & Distroless
How should secrets be passed into a container, and why not just use environment variables?
Secrets should be delivered as runtime-mounted files (Docker secrets, Kubernetes Secrets volumes) or fetched from an external vault at startup, not passed via plain environment variables or baked into the image. Environment variables are visible via docker inspect, are readable from /proc/<pid>/environ by anything with sufficient host access, and frequently leak into logs, crash dumps, and CI output — file-based or vault-based delivery avoids all of these exposure paths.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response