Apparently it is not possible to perform a security scan for vulnerabilities in a Docker image using Anchore Grype unless that image was previously pushed to a registry.
This makes it currently unsuitable for gating your registry from vulnerable images, because an image can be pushed there and then - before your scan is complete - this infected image with some severe CVEs can be immediately pulled by an unsuspecting user (before the image gets withdrawn).
How to work around this problem?
To reproduce the problem
- First
docker build
an image; do not push it to the registry. - Try to scan the locally available image with
grype
and you will get an error like this:
$ ./scan-with-grype-dockerized.sh mirekphd/ml-cache:20230726
[0000] INFO grype version: 0.64.2
1 error occurred:
* failed to catalog: unable to load image: unable to use OciRegistry source: failed to get image descriptor from registry: GET https://index.docker.io/v2/mirekphd/ml-cache/manifests/20230726: MANIFEST_UNKNOWN: manifest unknown; unknown tag=20230726