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.

Terminal
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:

Terminal
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.

Terminal
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:

Terminal
trivy image --input python-img --severity HIGH,CRITICAL
grype oci-dir:python-img
Heads up
Do not pass the .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

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.

Terminal
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.

Terminal
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.

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.