`trivy image` shows 300 vulnerabilities in your app image. How do you bring this down?
BeginnerScenarioContainer and IaC Security
Answer
Situation read → Most findings come from the OS layer and unused packages, not your code.
What I'd do →
- Group by layer and package:
trivy image --format table app:1.0. - Switch to a smaller, regularly rebuilt base image.
- Remove packages you do not need (
apt-get purge, no curl/wget in final image). - Rebuild weekly to pick up base image patches.
- Filter on actionable items:
--severity HIGH,CRITICAL --ignore-unfixed.
Why → One base image switch often removes 80% of findings.
Interview tip → Say you prioritise fixable and exploitable findings, not raw counts.
More on Container and IaC Security
A team asks whether to use `ubuntu`, `alpine` or a distroless base image. How do you advise?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