Interview Prep/DevOps Fundamentals/Security basics for DevOps

What is container image scanning, and where should it happen?

BeginnerConceptSecurity basics for DevOps
Answer

In one line: Container image scanning checks the OS packages and application libraries inside an image for known vulnerabilities, misconfigurations and secrets — and it should happen in the pipeline, in the registry and continuously after deployment.

What scanners look for:

  • Vulnerable OS packages (for example an old OpenSSL in the base image).
  • Vulnerable application dependencies (npm, pip, Maven, Go modules).
  • Embedded secrets (keys accidentally copied into the image).
  • Misconfigurations — running as root, no healthcheck, latest base image.
  • Licence issues.

Tools: Trivy, Grype, Docker Scout, Snyk Container, Clair, AWS ECR scanning (with Inspector), Microsoft Defender for Containers, Harbor's built-in scanner.

Where to scan (defence in depth):

  1. In the CI pipeline — right after docker build and before pushing; fail the build on critical issues.
    docker build -t orders:${GIT_SHA} .
    trivy image --severity CRITICAL --exit-code 1 orders:${GIT_SHA}
    docker push orders:${GIT_SHA}
    
  2. In the registry — scan on push, and re-scan regularly, because new CVEs are published for images that haven't changed.
  3. At deploy time — admission controllers (Kyverno, OPA Gatekeeper) can block images that weren't scanned or signed, or that come from untrusted registries.
  4. In running clusters — tools like Trivy Operator report vulnerabilities in workloads that are already running.

Reducing findings:

  • Use minimal base images (distroless, Alpine, slim, Chainguard).
  • Multi-stage builds so build tools aren't in the final image.
  • Rebuild images regularly to get patched base layers.
  • Generate an SBOM for each image so you can quickly check if you're affected by a new CVE.

Tip for interviews: mention "scan in CI, scan in the registry, enforce at admission and keep re-scanning" — it shows you know vulnerabilities appear after build time too.

All DevOps Fundamentals questions

More on Security basics for DevOps