Interview Q&A / Docker & Kubernetes

IntermediateQuick answer1 min readUpdated 3 Oct 2026

How do you scan Docker images for known vulnerabilities?

SHORT ANSWER

Use a scanner such as Trivy, Grype or Docker Scout to compare packages in the image against CVE databases. Run it in CI, fail builds on high severity issues, and rebuild regularly on updated base images.

Explain it simply

Like a medical check-up before boarding: the scanner lists what is inside your image and checks it against a database of known problems (CVEs).

trivy image myapp:1.0 reads the OS packages and language dependencies, such as pip or npm packages, and prints findings with severity from LOW to CRITICAL and the version that fixes each. Put it in your CI pipeline with --exit-code 1 --severity HIGH,CRITICAL so a risky image never reaches the registry. Registries like ECR and Docker Hub can also scan on push.

Findings change daily as new CVEs are published, so an image that was clean last month may not be today. Rebuild on fresh base images regularly, use small bases to reduce what can be flagged, and treat unfixable or unreachable findings with a documented exception rather than ignoring the scan.

Example

bash
trivy image myapp:1.0
trivy image --exit-code 1 --severity HIGH,CRITICAL myapp:1.0
docker scout cves myapp:1.0

What to say in the interview

"I scan with Trivy, Grype or Docker Scout, ideally in CI with a failing threshold for high and critical issues. Because new CVEs appear constantly, I rebuild on updated small base images and rescan regularly."

Common mistakes

  • Scanning once at release and never again.

#docker#security#scanning

Related questions

Practise more Docker & Kubernetes questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Docker & Kubernetes quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.