$ run as a normal user# run as root (or with sudo)
The quick answer
Step by step
- Install — one binary (see the full guide) or the container
anchore/grype. The first run downloads the vulnerability database (update daily withgrype db update). - Scan the project folder (line 1) — reads lock files (
package-lock.json,requirements.txt/poetry.lock,go.sum,pom.xml…). Lock files give exact versions; without them results are incomplete. - Scan an image (line 2) — OS packages and language packages inside.
--only-fixedhides findings with no fix yet, so the list shows what you can act on today. - Read the table —
NAME,INSTALLED,FIXED-IN,TYPE,VULNERABILITY,SEVERITY. Fix by upgrading the package (or the base image) to theFIXED-INversion. - SBOM first, scan later — make the SBOM once at build time with Syft, keep it with the release, and scan it again whenever new CVEs appear — no need to pull the image:
syft registry.example.com/shop/api:1.4.2 -o cyclonedx-json > sbom-api-1.4.2.json
grype sbom:sbom-api-1.4.2.json- Accept a finding with a reason — not exploitable in your use, fix planned:
only-fixed: true
ignore:
- vulnerability: CVE-2024-12345
reason: "Only affects the CLI tool, not used at runtime. Re-check 2026-12-31."- In CI (line 3) —
--fail-on highexits with an error when a high or critical finding is present. Add-o sarif > grype.sarifto show results in the pull request. - Keep it fresh — rebuild images regularly (new base image = new OS fixes), and let Dependabot/Renovate open upgrade PRs.
Check that it worked
The scan prints a table (or No vulnerabilities found); after upgrading the flagged package the finding is gone; in CI a test branch with an old library fails at the Grype step with discovered vulnerabilities at or above the severity threshold.
Common problems
| Problem | Cause | Fix |
|---|---|---|
dir: scan finds almost nothing | No lock files committed. | Commit lock files; scan after dependency install. |
| Very long list on an old image | Old base image. | Update the base image first — it removes most findings. |
| Same CVE ignored forever | Ignore without review date. | Reason + date in .grype.yaml; review regularly. |
failed to load vulnerability db | No internet in CI. | Cache or mirror the DB; GRYPE_DB_CACHE_DIR. |
| Results differ from Trivy | Different databases and matching. | Pick one as the gate; use the other for a second opinion. |
| Private registry access denied | No login for Grype. | docker login first, or registry credentials in env vars. |
Go further
- Command pages: grype, syft, trivy.
- Next how-tos: Create an SBOM for an image, Scan a container image for vulnerabilities, Sign and verify an image with Cosign, Check code quality with SonarQube.
- Learn it: Supply chain services — Grype, GitHub Actions — Dependencies. Full guide: Grype.
1Why scan an SBOM instead of the image again?
The SBOM lists all packages of a release; scanning it again finds newly published CVEs without pulling or rebuilding the image.
2What does --only-fixed do?
It hides vulnerabilities that have no fixed version yet, so the list shows only what you can fix now.