Interview Prep/DevSecOps/Container image and IaC scanning

Trivy flags CVEs in `/usr/local/lib/python3.12/site-packages/pip` inside the runtime image

BeginnerTroubleshootingContainer image and IaC scanning
Answer

Likely causes → The official Python image ships pip, setuptools and wheel; old versions carry CVEs, even though your app never runs pip at runtime.

Diagnose → trivy image --pkg-types library myapp:1.4 | grep -E "pip|setuptools"

Fix → Upgrade or remove them in the final stage:

RUN pip install --no-cache-dir -U pip setuptools && pip uninstall -y pip

Or use a multi-stage build that copies only the venv into a distroless Python base.

Prevent → Minimal runtime stages; build tools stay in the builder stage.

All DevSecOps questions

More on Container image and IaC scanning