Scan container images for vulnerabilities on a Mac
Trivy and Grype are free, open-source scanners that compare the packages in an image with databases of known vulnerabilities. They read Docker images directly. Apple's container tool has no scan command and no Docker socket, so you save the image first. This guide shows both ways, how to read the findings, how to write an SBOM and how to scan from Gantry.
In short. Run brew install trivy grype. On Docker, run trivy image app:dev. On Apple container, save the image with container image save --platform linux/arm64 -o app.tar app:dev, unpack it with tar -xf app.tar -C app-img, and scan the folder: trivy image --input app-img or grype oci-dir:app-img. Both tools refuse the tar file itself.
Install a scanner
Install one scanner or both with Homebrew. Each one downloads its vulnerability database on the first scan, which takes a minute.
brew install trivy grype
We checked the commands in this guide with Trivy 0.76.2, Grype 0.121.3 and container 1.7.1. Gantry needs Trivy 0.50.0 or Grype 0.74.0 or later.
Scan a Docker image
With a Docker engine (Docker Desktop, OrbStack or Colima), both tools read a local image by its name through the Docker socket:
trivy image app:dev
grype app:dev
Scan an Apple container image
Save the image to an OCI archive and unpack it into a folder. Pass --platform: when the image store has only some platforms of an image, container image save fails without it.
container image pull python:3.11-slim
container image save --platform linux/arm64 -o python.tar python:3.11-slim
mkdir python-img && tar -xf python.tar -C python-img
Then scan the folder. Trivy reads it with --input, Grype with the oci-dir: prefix:
trivy image --input python-img --severity HIGH,CRITICAL
grype oci-dir:python-img
.tar file. The archive of container image save starts with the entry ./: Trivy reports “file manifest.json not found in tar”, and Grype rejects it as a “potential path traversal attack”. The unpacked folder works with both.Read the results
- Severity: Critical, High, Medium, Low or Unknown. Start with Critical and High.
--severity HIGH,CRITICALlimits the Trivy output. - Installed and fixed version: if a fixed version exists, update the base image or the package and build again.
trivy --ignore-unfixedandgrype --only-fixedhide findings without a fix. - “won't fix”: the distribution decided not to fix the package in this release. Use a newer base image, or accept the risk.
- Two tools, two databases: Trivy and Grype often report different counts. Neither is wrong; they use different sources.
Export an SBOM
A software bill of materials lists every package in the image. Trivy writes CycloneDX and SPDX; Grype's companion Syft writes both too.
trivy image --input python-img --format cyclonedx -o sbom.cdx.json
trivy image --input python-img --format spdx-json -o sbom.spdx.json
Fail a build on high findings
In a script, let the scanner set the exit code. Grype exits with a non-zero code when a finding of the given severity or higher exists; with Trivy, use --exit-code 1 --severity HIGH,CRITICAL.
grype oci-dir:python-img --fail-on high
echo $?
Scan from Gantry
Gantry 0.29.0 does these steps for you. Choose Scan for Vulnerabilities… in the image menu or the image detail toolbar.
- Gantry finds Trivy or Grype in
GANTRY_TRIVYorGANTRY_GRYPE, inPATH, or in/opt/homebrew/binand/usr/local/bin. Trivy is the default when both are installed. Without a scanner, the sheet shows the Homebrew commands. - On apple/container, Gantry saves the image with
--platform, unpacks it and scans the folder. On local Docker, it scans a saved archive. On Docker over SSH, it scans the registry copy of the tag. - The findings are grouped by severity, with a symbol and a word, not only a color. Each row has the ID with a link, the package, the installed version and the fixed version. A filter finds a package or an ID.
- Export SBOM writes CycloneDX (both tools) or SPDX (Trivy).
- Stop or closing the sheet stops the scanner and removes the temporary files.
Related guides
- Move from Docker Desktop to Apple container: commands, Compose, volumes and gaps
- Store containers and volumes on an external drive on a Mac
- Create a container from a docker run command on Mac (docker run to container run)
- Apple container GUI for Mac: the complete apple/container guide
- Kubernetes on Apple container: a GUI for container cluster and a Kubernetes browser
- Gantry vs Docker Desktop vs OrbStack vs Podman Desktop on Mac (2026)
Questions and answers
How do I scan an Apple container image for vulnerabilities?
Save it with container image save --platform linux/arm64 -o app.tar app:dev, unpack it with tar -xf app.tar -C app-img, then run trivy image --input app-img or grype oci-dir:app-img. Gantry does these steps with Scan for Vulnerabilities….
Why does Trivy or Grype fail on the archive from container image save?
The archive starts with the entry ./. Trivy does not find manifest.json or index.json in it, and Grype treats the entry as a path traversal. Unpack the archive and scan the folder.
Trivy or Grype: which one should I use?
Both are free and open source. Trivy also finds secrets and misconfigurations and writes SPDX; Grype is small and focused on packages. They use different databases, so running both finds more. Gantry uses Trivy when both are installed.
Does Gantry install the scanners?
No. Install them with brew install trivy grype. Gantry looks in PATH, /opt/homebrew/bin and /usr/local/bin, or in GANTRY_TRIVY and GANTRY_GRYPE.
Do I need Docker Scout or a Docker account to scan images?
No. Trivy and Grype work without an account, on Docker images and on Apple container images.
Last updated 2026-11-23.