A team asks whether to use `ubuntu`, `alpine` or a distroless base image. How do you advise?
BeginnerScenarioContainer and IaC Security
Answer
Situation read → Fewer packages means fewer CVEs and less attacker tooling, but also harder debugging.
What I'd do →
- Recommend distroless or a minimal Chainguard/Wolfi-style image for production services in compiled languages.
- Use Alpine when the team needs a shell and a package manager, and accept musl compatibility quirks.
- Use Ubuntu or Debian slim only when software needs glibc and many system libraries.
- Pair with multi-stage builds so compilers never reach the runtime image.
- Debug with
kubectl debugephemeral containers instead of baking in a shell.
Why → Attack surface scales with the number of installed packages.
Interview tip → Mention that smaller does not mean automatically patched; you still rescan.
More on Container and IaC Security
`trivy image` shows 300 vulnerabilities in your app image. How do you bring this down?BeginnerA Dockerfile runs the app as root. How do you fix it and prove the fix?IntermediateCheckov fails a Terraform PR because an S3 bucket allows public access. What do you change?BeginnerHow do you set up image scanning so nothing vulnerable reaches production?IntermediateAn image passed scanning three weeks ago and runs in production. A new critical CVE is published today. What happens next?IntermediateYou find `ENV DB_PASSWORD=...` and `ARG NPM_TOKEN` in a Dockerfile. What is wrong and how do you fix it?Beginner