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 buildan image; do not push it to the registry. - Try to scan the locally available image with
grypeand 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
As a workaround, you may consider running
grypeas therootuser (please test it on an image that wasn't previously pushed to the Docker Hub):Note: if you got Critical vulnerabilities above by not using the
--only-fixedflag here, then be assured that they are relevant only for systems other than Alpine actually used in that image - one for Debian and one for... Windows, in a separate bug I've already reported to the developers.