Every image carries an operating system and libraries that may have known vulnerabilities. Trivy (Aqua Security, open source) scans an image in seconds.
# run without installing
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
aquasec/trivy:0.14.0 image myapp:1.0
# fail a CI job on serious findings
trivy image --exit-code 1 --severity HIGH,CRITICAL myapp:1.0
Reading the result: each row lists the library, the CVE, the installed version and the fixed version. Many findings are fixed by rebuilding on a newer base image, so scan regularly, not only once.
Reduce the exposure:
- Start from a small base (
alpine:3.13, or a distroless image). - Use multi-stage builds so compilers are not shipped.
- Run as a non-root
USER. - Pin versions and rebuild on a schedule.
Scanning is one layer; it does not replace patching running hosts or limiting what the container can reach.