How do you set up image scanning so nothing vulnerable reaches production?
IntermediateScenarioContainer and IaC Security
Answer
Situation read → Scanning in CI alone is not enough, since images can be pushed from elsewhere and age after the build.
What I'd do →
- Scan in CI and fail on policy:
trivy image --exit-code 1 --severity CRITICAL --ignore-unfixed $IMAGE. - Enable registry scanning (ECR enhanced scanning, Harbor with Trivy) for continuous rescans.
- Allow only images from your registry via admission policy.
- Require a signature and attestation of a passed scan at admission (Kyverno
verifyImages). - Alert on new CVEs for images already deployed.
Why → The build-time gate stops bad images, admission stops bypasses, continuous scan handles aging.
Interview tip → Describe it as three layers: build, registry, cluster.
More on Container and IaC Security
A team asks whether to use `ubuntu`, `alpine` or a distroless base image. How do you advise?Beginner`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?BeginnerAn 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