Day 13: Vulnerability scanners – trivy, grype, docker scout
Goal: You scan images, source code and configuration with trivy, separate SBOM generation and scanning with syft and grype, and know docker scout as an alternative. · Duration: approx. 90 min · Prerequisite: Day 12
Briefing
- A scanner lists the packages in the image (operating system and languages) and matches them against a vulnerability database. Result: CVEs with a severity and – if there is one – the version with the fix.
- trivy (Aqua Security) is the Swiss Army knife: images, folders, configuration, secrets, SBOMs. grype (Anchore) only scans – but it also scans SBOMs from syft.
- docker scout is Docker’s own service; the CLI plugin needs Docker and a Docker account.
- Databases are big (trivy 1.6 GB, grype 3.2 GB unpacked) and change daily. All CVE counts in this chapter are a snapshot from 10/30/2026.
image ──trivy image──────────────────────────► findings
──syft──► SBOM (CycloneDX) ──grype sbom:──► findings (pipeline: SBOM once,
└─trivy sbom───► findings scan as often as you like)
Drill 1: trivy – install it and scan the first image
| Profile | trivy |
|---|---|
| Task | Find vulnerabilities, misconfigurations, secrets and licenses |
| Special feature | One binary for images, file systems, repos, IaC, SBOMs and Kubernetes |
| Project | github.com/aquasecurity/trivy (Apache-2.0), docs at trivy.dev |
| Version in this book | 0.76.1 |
source ~/ct-lab/setup/env.sh
mkdir -p ~/ct-lab/tag13 && cd ~/ct-lab/tag13
cp -R "$LAB/code/notes/." . && cp -R "$LAB/code/tag12/notes/." .
trivy --version | head -1
df -h ~ | tail -1Expected (shortened):
Version: 0.76.1
/dev/sda1 38G 6.7G 32G 18% /
Plan for at least 5 GB of free space. The first scan downloads the
database to ~/.cache/trivy:
trivy image docker.io/library/nginx:1.30.6-alpine 2>&1 | head -24 | cut -c1-88Expected (shortened; times and numbers will differ for you):
… INFO [vulndb] Need to update DB
… INFO [vulndb] Downloading vulnerability DB...
… INFO [vulndb] Downloading artifact... repo="mirror.gcr.io/aquasec/trivy-db:2"
…
… INFO Detected OS family="alpine" version="3.24.3"
… INFO [alpine] Detecting vulnerabilities... os_version="3.24" repository="3.24"
…
Report Summary
┌───────────────────────────────────────────────────────┬────────┬─────────────────┬──
│ Target │ Type │ Vulnerabilities │ S
├───────────────────────────────────────────────────────┼────────┼─────────────────┼──
│ docker.io/library/nginx:1.30.6-alpine (alpine 3.24.3) │ alpine │ 49 │
└───────────────────────────────────────────────────────┴────────┴─────────────────┴──
After that comes
Total: 49 (UNKNOWN: 0, LOW: 44, MEDIUM: 2, HIGH: 2, CRITICAL: 1)
and a wide table per finding: package, CVE, severity, status, installed
version, fixed version, title. By default, trivy looks for
vulnerabilities and secrets;
--scanners vuln skips the secret search. JSON makes it more
compact:
trivy image -q --severity HIGH,CRITICAL -f json docker.io/library/nginx:1.30.6-alpine \
| jq -r '.Results[].Vulnerabilities[]? | [.Severity, .PkgName, .InstalledVersion,
.FixedVersion, .VulnerabilityID] | join(" ")'Expected:
CRITICAL brotli-libs 1.2.0-r1 1.2.1-r0 CVE-2026-111497
HIGH curl 8.22.0-r0 8.23.0-r0 CVE-2026-92392
HIGH libcurl 8.22.0-r0 8.23.0-r0 CVE-2026-92392
All three have a fix in Alpine – a freshly built nginx image gets rid of them.
Save your progress? Sign up for free
Drill 2: Where trivy gets the image from
Where did trivy get the nginx image from? It asks Docker, containerd,
Podman and finally the registry, in that order (--image-src
changes the order). Thanks to DOCKER_HOST from Day 4,
“Docker” is already the Podman socket. Without the socket it looks like
this:
systemctl --user stop podman.socket podman.service
trivy image -q --scanners vuln localhost/notes-api:0.1.0 2>&1 | grep -E '^\s+\*' \
| cut -c1-84Expected:
* docker error: unable to inspect the image (localhost/notes-api:0.1.0): Cannot con
* containerd error: failed to list images from containerd client: connection error:
* podman error: unable to inspect the image (localhost/notes-api:0.1.0): http error
* remote error: Get "https://localhost/v2/": dial tcp [::1]:443: connect: connectio
Four sources, four errors – the registry localhost
doesn’t exist. With the socket it works:
systemctl --user start podman.socket
trivy image -q --scanners vuln localhost/notes-api:0.1.0 -f json \
| jq -r '.Results[] | "\(.Target) \(.Type) \(.Vulnerabilities | length)"'Expected:
notes-api gobinary 2
Without the socket, the archive remains:
podman save -o x.tar … and
trivy image --input x.tar. The notes-api binary on
scratch has no operating system – trivy reads the Go
modules directly from the binary. Two of them are vulnerable (Drill
4).
Save your progress? Sign up for free
Drill 3: Filters and gates
trivy image -q --scanners vuln --severity HIGH,CRITICAL --exit-code 1 \
docker.io/library/nginx:1.30.6-alpine >/dev/null; echo "Exit: $?"
trivy image -q --scanners vuln --severity CRITICAL --exit-code 1 \
localhost/notes-api:0.1.0 >/dev/null; echo "Exit: $?"Expected:
Exit: 1
Exit: 0
--severity filters the display, --exit-code
turns every remaining finding into an error.
--ignore-unfixed gets interesting on the Debian-based
worker:
trivy image -q --scanners vuln --table-mode summary localhost/notes-worker:0.1.0 \
| grep -E 'debian|Python ' | tr -s ' '
trivy image -q --scanners vuln --ignore-unfixed --table-mode summary \
localhost/notes-worker:0.1.0 | grep -E 'debian|Python ' | tr -s ' 'Expected:
│ localhost/notes-worker:0.1.0 (debian 13.7) │ debian │ 164 │
│ Python │ python-pkg │ 8 │
│ localhost/notes-worker:0.1.0 (debian 13.7) │ debian │ 0 │
│ Python │ python-pkg │ 8 │
None of the 164 Debian vulnerabilities has a fix today (status
affected or fix_deferred) – you can only wait
them out or choose a smaller base image. The 8 Python findings
(urllib3, setuptools, msgpack)
have a fix. Exactly these belong in the gate:
--ignore-unfixed --exit-code 1.
Save your progress? Sign up for free
Drill 4: Exceptions with
.trivyignore
notes-api contains golang.org/x/text v0.29.0 with two
HIGH findings. Suppose the update is scheduled: until then, you document
the exception – with an expiry date.
cat > .trivyignore <<'EOF'
# .trivyignore – state at end of Day 13: deliberately accepted findings, each with reason and expiry
# golang.org/x/text v0.29.0 in notes-api: update scheduled (ticket LAB-13)
CVE-2026-56851 exp:2026-12-31
CVE-2026-56852 exp:2026-12-31
EOF
trivy image -q --scanners vuln --exit-code 1 --show-suppressed \
localhost/notes-api:0.1.0 | grep -E 'Total|CVE|Suppressed' | tr -s ' '
echo "Exit: ${PIPESTATUS[0]}"Expected:
Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)
Suppressed Vulnerabilities (Total: 2)
│ golang.org/x/text │ CVE-2026-56851 │ HIGH │ ignored │ N/A │ .trivyignore │
│ │ CVE-2026-56852 │ │ │ │ │
Exit: 0
trivy reads .trivyignore from the current folder
(--ignorefile picks a different one). After the expiry date
the line no longer applies and the gate fires again – that way “later”
doesn’t turn into “never”.
Save your progress? Sign up for free
Drill 5: Code, configuration and secrets
trivy also scans the project folder – lock files instead of the image:
trivy fs -q --scanners vuln --table-mode summary . | grep -E '│ [a-z]' | tr -s ' 'Expected:
│ notes-api/go.mod │ gomod │ 0 │
│ notes-web/package-lock.json │ npm │ 0 │
│ notes-worker/uv.lock │ uv │ 0 │
Zero for go.mod? The .trivyignore from
Drill 4 applies to every trivy run in this folder. With
--ignorefile '', the same two Go findings as in the image
show up – even before the build. trivy config checks
Dockerfiles (and Kubernetes YAML, Terraform, Helm …) for
misconfigurations:
trivy config -q --table-mode summary . | grep -E '│ notes' | tr -s ' '
trivy config -q notes-api/Containerfile.besser | grep -E '^DS-'Expected:
│ notes-api/Containerfile.besser │ dockerfile │ 2 │
│ notes-api/Containerfile.lint │ dockerfile │ 6 │
│ notes-api/Containerfile.schlecht │ dockerfile │ 3 │
│ notes-api/Dockerfile │ dockerfile │ 0 │
│ notes-pod.yaml │ kubernetes │ 53 │
│ notes-web/Dockerfile │ dockerfile │ 1 │
│ notes-worker/Dockerfile │ dockerfile │ 1 │
DS-0002 (HIGH): Specify at least 1 USER command in Dockerfile with non-root user as
argument
DS-0026 (LOW): Add HEALTHCHECK instruction in your Dockerfile
The Dockerfile checks overlap with hadolint (Day 12). Along the way,
trivy recognized notes-pod.yaml from Day 2 as a Kubernetes
manifest and reported 53 findings –
trivy config notes-pod.yaml shows them one by one. Finally,
secrets. A lab key that accidentally ended up in the
project folder:
ssh-keygen -q -t ed25519 -N '' -C lab-deploy -f notes-api/deploy_key
trivy fs -q --scanners secret notes-api | grep -A1 -E '^HIGH'
podman build -q --format docker -f notes-api/Containerfile.schlecht \
-t localhost/notes-api:schlecht notes-api >/dev/null 2>&1
trivy image -q --scanners secret --exit-code 1 localhost/notes-api:schlecht \
| grep -E 'added by' | cut -c1-80; echo "Exit: ${PIPESTATUS[0]}"Expected:
HIGH: AsymmetricPrivateKey (private-key)
════════════════════════════════════════
/src/deploy_key:2-6 (offset: 36 bytes) (added by 'COPY dir:a7bee93a0cc5f5462d43
Exit: 1
COPY . . carried the key into the image; trivy even
names the layer. The .dockerignore of notes-api excludes
*.key and *.pem, but not
deploy_key. Clean up and rebuild the bad image without the
key:
rm notes-api/deploy_key notes-api/deploy_key.pub
podman build -q --format docker -f notes-api/Containerfile.schlecht \
-t localhost/notes-api:schlecht notes-api >/dev/null 2>&1
trivy image -q --scanners secret --exit-code 1 localhost/notes-api:schlecht \
>/dev/null; echo "Exit: $?"Expected:
Exit: 0
Save your progress? Sign up for free
Drill 6: Database and cache
trivy version | sed -n '1,5p'
du -sh ~/.cache/trivy/db
time trivy image -q --skip-db-update --scanners vuln --severity CRITICAL \
docker.io/library/nginx:1.30.6-alpine | grep TotalExpected (shortened):
Version: 0.76.1
Vulnerability DB:
Version: 2
UpdatedAt: 2026-10-30 19:07:50.77378237 +0000 UTC
NextUpdate: 2026-10-31 19:07:50.77378224 +0000 UTC
1.6G /home/ubuntu/.cache/trivy/db
Total: 1 (CRITICAL: 1)
real 0m0.687s
The database is an OCI artifact
(mirror.gcr.io/aquasec/trivy-db:2, fallback
ghcr.io/aquasecurity/trivy-db:2); trivy downloads it again
as soon as NextUpdate has passed.
--skip-db-update scans offline with the existing state –
important when many pipelines run in parallel. --cache-dir
puts the cache somewhere else, trivy clean --vuln-db (or
--all) deletes it.
Save your progress? Sign up for free
Drill 7: grype – the second scanner
| Profile | grype |
|---|---|
| Task | Find vulnerabilities in images, folders and SBOMs |
| Special feature | Scans syft SBOMs directly; risk ranking with EPSS and KEV |
| Project | github.com/anchore/grype (Apache-2.0) |
| Version in this book | 0.121.0 |
grype version | grep -E '^(Version|Syft Version|Supported DB)'
time grype db update | tail -1
grype db status | grep -E '^(Built|Status)'
du -sh ~/.cache/grypeExpected (shortened):
Version: 0.121.0
Syft Version: v1.55.0
Supported DB Schema: 6
Vulnerability database updated to latest version!
real 4m27.467s
…
Built: 2026-10-30T06:23:28Z
Status: valid
3.2G /home/ubuntu/.cache/grype
grype ships with syft as a library and downloads its database from
grype.anchore.io. grype, too, needs the socket for local
Podman images; you choose the source with a prefix
(podman:, registry:,
oci-archive:, dir:, sbom:):
grype -q podman:docker.io/library/nginx:1.30.6-alpine | head -6 | cut -c1-88Expected:
NAME INSTALLED FIXED IN TYPE VULNERABILITY SEVERITY EPSS RIS
brotli-libs 1.2.0-r1 1.2.1-r0 apk CVE-2026-111497 Critical 82.6% (99th) 98.
curl 8.22.0-r0 8.23.0-r0 apk CVE-2026-92392 High 1.3% (70th) 1.0
libcurl 8.22.0-r0 8.23.0-r0 apk CVE-2026-92392 High 1.3% (70th) 1.0
curl 8.22.0-r0 8.23.0-r0 apk CVE-2026-92387 High 0.3% (27th) 0.3
libcurl 8.22.0-r0 8.23.0-r0 apk CVE-2026-92387 High 0.3% (27th) 0.3
grype sorts by risk: EPSS (probability of an attack in the next 30
days) and kev (listed in CISA’s catalog of actively
exploited vulnerabilities). That makes the brotli vulnerability clearly
the first thing to fix – in the RISK column cut off by cut,
it shows 98.7 (kev), all others at most 1.0. Same image,
different count than trivy:
grype -q podman:docker.io/library/nginx:1.30.6-alpine -o json \
| jq -r '.matches[].vulnerability.severity' | sort | uniq -cExpected:
5 Critical
12 High
3 Medium
32 Unknown
trivy reports 1 CRITICAL and 2 HIGH. Both find the same packages but
take their severities from different sources – trivy prefers the
distribution’s rating and warns with
Using severities from other vendors when it has to fall
back. For the pipeline, what matters is therefore which
scanner you commit to with which threshold. Gates in grype:
grype -q podman:docker.io/library/nginx:1.30.6-alpine --fail-on critical \
>/dev/null; echo "Exit: $?"
grype -q registry:$REG/notes/notes-api:0.1.0 --only-fixed | cut -c1-72Expected:
Exit: 2
NAME INSTALLED FIXED IN TYPE VULNERABILITY SEVERITY
golang.org/x/text v0.29.0 0.39.0 go-module GO-2026-5970 High
golang.org/x/text v0.29.0 0.41.0 go-module GO-2026-6629 High
--fail-on returns exit 2 (not 1),
--only-fixed hides vulnerabilities without a fix.
registry: reads directly from your registry, login from
~/.docker/config.json. For Go, grype reports the IDs from
the Go database; --by-cve shows the CVE numbers instead –
the same as trivy.
Save your progress? Sign up for free
Drill 8: SBOM once, scan as often as you like – syft + grype
A scan from the image takes time, because the scanner first unpacks and catalogs the image. In a pipeline, you generate the SBOM once at build time (syft, in detail on Day 14) and then scan it as often as you like – at night, with a new database, without the image:
syft -q podman:docker.io/library/nginx:1.30.6-alpine -o cyclonedx-json > nginx.cdx.json
ls -l nginx.cdx.json | awk '{print $5, $9}'
time grype -q sbom:nginx.cdx.json --only-fixed --fail-on critical | wc -l
trivy sbom -q --table-mode summary nginx.cdx.json | grep alpine | tr -s ' 'Expected:
481929 nginx.cdx.json
50
real 0m37.239s
│ nginx.cdx.json (alpine 3.24.3) │ alpine │ 24 │
Both scanners take the same CycloneDX file. grype still needs a good 30 s – most of the time goes into loading the 3 GB database, not the SBOM. Via the SBOM, trivy finds 24 instead of 49 findings: package detection in syft and trivy differs in the details. So in a pipeline, stick with one SBOM tool and one scanner per gate.
As a script for the pipeline (included in the companion code):
cat > sbom-scan.sh <<'EOF'
#!/usr/bin/env bash
# sbom-scan.sh – state at end of Day 13: generate the SBOM once, then scan separately
# Usage: ./sbom-scan.sh <source> [threshold], e.g.
# ./sbom-scan.sh podman:localhost/notes-api:0.1.0 high
set -euo pipefail
src=${1:?Quelle angeben, z. B. podman:localhost/notes-api:0.1.0}
fail_on=${2:-high}
name=$(basename "${src#*:}" | tr ':@' '__')
sbom="$name.cdx.json"
syft -q "$src" -o cyclonedx-json="$sbom"
echo "✔ SBOM $sbom: $(jq '.components | length' "$sbom") Komponenten"
if grype -q "sbom:$sbom" --only-fixed --fail-on "$fail_on" -o json > "$name.grype.json"
then
echo "✔ grype: kein behebbarer Befund ab $fail_on"
else
rc=$?
echo "✘ grype: behebbare Befunde ab $fail_on (Exit $rc)"
jq -r '.matches[] | [.vulnerability.severity, .artifact.name, .vulnerability.id]
| " " + join(" ")' "$name.grype.json" | sort -u | head -5 || true
exit "$rc"
fi
EOF
chmod +x sbom-scan.sh && bash -n sbom-scan.sh
./sbom-scan.sh podman:localhost/notes-api:0.1.0 high; echo "Exit: $?"Expected (Komponenten = components,
behebbare Befunde ab high = fixable findings from high
upward):
✔ SBOM notes-api_0.1.0.cdx.json: 10 Komponenten
✘ grype: behebbare Befunde ab high (Exit 2)
High golang.org/x/text GO-2026-5970
High golang.org/x/text GO-2026-6629
Exit: 2
The SBOM stays around as an artifact – on Day 14 it gets attached to the image, signed.
Save your progress? Sign up for free
Drill 9: docker scout
| Profile | docker scout |
|---|---|
| Task | Analyze images, show CVEs and better base images |
| Special feature | Docker CLI plugin; matching on the Docker Scout platform, Docker account required |
| Project | docs.docker.com/scout, binaries: github.com/docker/scout-cli |
| Version in this book | v1.29.0 (plugin), Docker CE 29.9.2 |
docker scout is the only tool in this book that requires Docker. Docker Desktop ships with it; on Ubuntu you install Docker CE from Docker’s apt repository and the plugin separately (docs.docker.com/engine/install/ubuntu and docs.docker.com/scout/install):
sudo apt update && sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
-o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
sudo tee /etc/apt/sources.list.d/docker.sources >/dev/null <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin \
docker-compose-pluginExpected:
Setting up containerd.io (2.4.2-3~ubuntu.26.04~resolute) ...
Setting up docker-compose-plugin (5.6.1-1~ubuntu.26.04~resolute) ...
Setting up docker-ce-cli (5:29.9.2-1~ubuntu.26.04~resolute) ...
Setting up docker-ce (5:29.9.2-1~ubuntu.26.04~resolute) ...
For docker to run without sudo, your user
belongs in the group docker – then log in again
(exit, multipass shell ct-lab) or use
newgrp docker for the current shell. And: since Day 4,
~/.bashrc sets DOCKER_HOST to the Podman
socket. As long as the variable is in effect, even the real
docker CLI talks to Podman instead of the Docker service.
For this drill, you unset it in the shell:
sudo usermod -aG docker "$USER"
newgrp docker
unset DOCKER_HOST
docker --version
systemctl cat containerd | head -1Expected:
Docker version 29.9.2, build a82e528
# /usr/local/lib/systemd/system/containerd.service
Warning: Since Day 6, nerdctl-full lives under
/usr/local. Itscontainerd.servicein/usr/local/lib/systemd/systemtakes precedence over the unit from thecontainerd.iopackage, and/usr/local/bin/containerdcomes before/usr/bin/containerdin thePATH. So Docker runs on nerdctl-full’s containerd. That works fine as long as both versions match (here both 2.4.2) – after updates, it’s worth runningsystemctl cat containerdandcontainerd --version. By the way, Docker 29 stores its images in the containerd namespacemoby, nerdctl indefault.
Docker provides the plugin as an install script or as a release archive. The docs recommend reading the script before running it:
curl -fsSL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh \
-o install-scout.sh
less install-scout.sh
sh install-scout.sh
docker scout versionExpected:
[info] fetching release script for tag='v1.29.0'
[info] using release tag='v1.29.0' version='1.29.0' os='linux' arch='arm64'
[info] installed /home/ubuntu/.docker/cli-plugins/docker-scout
…
Version: v1.29.0 (go1.26.10-X:jsonv2 - linux/arm64)
git commit: a05e1906e71808ff09ef3a375495b7ca6710da61
For the manual route, the docs put the binary
docker-scout into $HOME/.docker/scout and add
the folder as cliPluginsExtraDirs (absolute path) to
~/.docker/config.json. Careful: since Day 7, that file also
holds the registry logins – extend the file, don’t overwrite it.
Security: The one-line installation downloads a script from
main– without a pin and without a checksum. That’s acceptable in the lab; at a customer, a verified, versioned release belongs in the internal package repository.
docker scout needs a Docker account (docker login).
According to the docs, the image’s SBOM is matched against the database
of the Docker Scout platform, which combines more than 20 sources
(including NVD, GitHub Advisory Database, Alpine secdb, Debian Security
Tracker, CISA KEV, EPSS).
Without a user name, docker login uses browser-based
sign-in: it shows a one-time code and
https://login.docker.com/activate. You enter the code there
in the browser in which you’re signed in to Docker Hub – you never type
a password in the VM.
docker loginExpected (shortened):
USING WEB-BASED LOGIN
Your one-time device confirmation code is: XXXX-XXXX
Press ENTER to open your browser or submit your device code here:
https://login.docker.com/activate
Waiting for authentication in the browser…
WARNING! Your credentials are stored unencrypted in '/home/ubuntu/.docker/config.json'.
Login Succeeded
Security: Without a credential helper, the token ends up in plain text in
~/.docker/config.json– next to the lab logins from Day 7. At a customer, a credential store belongs in front of it (docs.docker.com/go/credential-store/); in the lab you log out again at the end of the day withdocker logout.
The three most important commands are quickview,
cves and recommendations:
docker scout quickview docker.io/library/nginx:1.30.6-alpineExpected:
Target │ nginx:1.30.6-alpine │ 3C 7H 5M 5L 17?
digest │ 4f7cab9e1cd0 │
Base image │ oisupport/staging-arm64v8:… │ 0C 0H 0M 0L 1?
Policy status FAILED (1/7 policies met)
Health score E (17%)
Status │ Policy │ Results
────────┼────────────────────────────────────────────────┼──────────────────────
! │ Image runs as the root user │
! │ Copyleft licensed packages found │ 35 packages
! │ Fixable critical or high vulnerabilities found │ 3C 6H 0M 0L
! │ High-profile vulnerabilities found │ 1C 0H 0M 0L
! │ Outdated base images found │
✓ │ No unapproved base images │ 0 deviations
! │ Required supply chain attestations missing │ 1 deviation
(Snapshot from 10/31/2026; tables shortened.) Here docker scout
doesn’t get the SBOM from the image itself but from the attestation that
the nginx project publishes with the image
(✓ SBOM obtained from attestation, 87 packages found). On
top of that come the platform’s policies – such as “runs as root” –
which neither trivy nor grype knows.
quickview (short qv) shows the CVE counts
per severity for the image and its base image. cves lists
the findings and can serve as a gate:
docker scout cves --only-severity critical,high --only-fixed --exit-code \
docker.io/library/nginx:1.30.6-alpine; echo "Exit: $?"Expected:
✗ Detected 2 vulnerable packages with a total of 9 vulnerabilities
## Overview
Target │ nginx:1.30.6-alpine
digest │ 4f7cab9e1cd0
platform │ linux/arm64/v8
vulnerabilities │ 3C 6H 0M 0L
packages │ 87
## Packages and Vulnerabilities
2C 6H 0M 0L curl 8.22.0-r0
✗ CRITICAL CVE-2026-87866
…
1C 0H 0M 0L brotli 1.2.0-r1
✗ CRITICAL CVE-2026-111497 CISA KEV
Affected range : <1.2.1-r0
Fixed version : 1.2.1-r0
9 vulnerabilities found in 2 packages
CRITICAL 3
HIGH 6
Exit: 2
The unshortened output is long: for each package, docker scout shows
the Dockerfile line of the layer it comes from. CISA KEV
marks vulnerabilities that, according to the US agency CISA, are already
being actively exploited.
--exit-code (short -e) returns exit 2 as
soon as vulnerabilities are found; --format knows
packages (default), sarif, spdx,
gitlab, markdown and sbom. You
choose the source by prefix: local:// (local only),
registry://, archive:// (file from
docker save), oci-dir://, fs://
and sbom:// – with that, docker scout scans a syft SBOM
too:
syft -q podman:docker.io/library/nginx:1.30.6-alpine -o spdx-json \
| docker scout cves sbom://Expected:
✗ Detected 6 vulnerable packages with a total of 37 vulnerabilities
## Overview
Target │ <stdin>
digest │ 4620b1c0abf8
platform │ linux/arm64
vulnerabilities │ 5C 13H 5M 5L 34?
packages │ 72
## Packages and Vulnerabilities
2C 6H 0M 0L 16? libcurl 8.22.0-r0
…
62 vulnerabilities found in 6 packages
CRITICAL 5
HIGH 13
The same scanner, the same image – and still more hits: the syft SBOM
lists libcurl as a separate package next to
curl, the nginx attestation doesn’t. The source of the SBOM
shapes the result.
Warning: If the Podman socket from Day 4 isn’t running, syft can’t find the image (
podman not available: no host address), writes empty output – and docker scout only reportsERROR unknown file format. Checksystemctl --user is-active podman.socketfirst.
Finally recommendations: which base image version would
have fewer vulnerabilities?
docker scout recommendations docker.io/library/nginx:1.30.6-alpineExpected:
Target │ nginx:1.30.6-alpine
digest │ 4f7cab9e1cd0
## Recommended fixes
Base image is oisupport/staging-arm64v8:d26051d6531a…
Refresh base image
✓ This image version is up to date.
Change base image
✓ There are no tag recommendations at this time.
For official images like nginx, docker scout often has nothing to recommend: they build on an internal staging base image, and 1.30.6 is current. The nine vulnerabilities above only go away with a new nginx build with updated curl and brotli.
--only-refresh shows only newer builds of the same tag,
--only-update only newer versions. For the notes images
(Podman): docker scout sees Docker’s own image store, not Podman’s – the
way there is via archive:// or sbom://.
The three scanners compared (facts from the docs and live testing):
| Feature | trivy | grype | docker scout |
|---|---|---|---|
| License | Apache-2.0 | Apache-2.0 | Docker Subscription Service Agreement |
| Database | OCI artifact trivy-db, local (1.6 GB) |
grype.anchore.io, local (3.2 GB) |
Docker Scout platform |
| Offline | yes (--skip-db-update) |
yes (load DB in advance) | no (Docker account required) |
| Targets | image, fs, repo, config, secret, sbom, k8s | image, folder, SBOM, PURL/CPE | image, archive, fs, SBOM |
| Formats | table, json, sarif, cyclonedx, spdx, … | table, json, cyclonedx, sarif, template | packages, sarif, spdx, gitlab, markdown, sbom |
| Gate | --exit-code n |
--fail-on → exit 2 |
--exit-code → exit 2 |
Save your progress? Sign up for free
Checkpoint
The socket and the databases of both scanners:
cd ~/ct-lab/tag13
systemctl --user is-active podman.socket
ls ~/.cache/trivy/db/
grype db status | grep -i statusExpected (shortened):
active
metadata.json
trivy.db
Status: valid
With .trivyignore, notes-api passes:
trivy image -q --scanners vuln --exit-code 1 localhost/notes-api:0.1.0 >/dev/null
echo "Exit: $?"Expected:
Exit: 0
sbom-scan.sh and the SBOM of notes-api:
ls -l sbom-scan.sh notes-api_0.1.0.cdx.json | cut -c1-10
jq -r .bomFormat notes-api_0.1.0.cdx.jsonExpected:
-rw-r--r--
-rwxrwxr-x
CycloneDX
Challenge
Really fix the two Go findings: raise golang.org/x/text
in notes-api to the version with the fix, build
localhost/notes-api:0.1.1 and show that trivy
without .trivyignore and
sbom-scan.sh with threshold high both
pass.
Hint: go get runs in the container
golang:1.27-alpine; trivy reads
--ignorefile '' as “no exceptions”.
Solution
podman run --rm -v "$PWD/notes-api:/src:Z" -w /src \
docker.io/library/golang:1.27-alpine \
sh -c 'go get golang.org/x/[email protected] && go mod tidy' >/dev/null 2>&1
grep 'golang.org/x/text' notes-api/go.mod
podman build -q --format docker --build-arg VERSION=0.1.1 \
-t localhost/notes-api:0.1.1 notes-api >/dev/null 2>&1
trivy image -q --scanners vuln --ignorefile '' --exit-code 1 \
localhost/notes-api:0.1.1 >/dev/null; echo "Exit: $?"
./sbom-scan.sh podman:localhost/notes-api:0.1.1 high; echo "Exit: $?"Expected (kein behebbarer Befund ab high = no fixable
finding from high upward):
golang.org/x/text v0.41.0 // indirect
Exit: 0
✔ SBOM notes-api_0.1.1.cdx.json: 10 Komponenten
✔ grype: kein behebbarer Befund ab high
Exit: 0
After that, the entries in .trivyignore are superfluous
– delete them. (The companion code code/tag13 keeps the old
version so that the drills above stay correct.)
Save your progress? Sign up for free
Enterprise Note
- Mirror scanner databases centrally (trivy:
--db-repositorypointing to your own registry; grype:GRYPE_DB_UPDATE_URL) – otherwise every pipeline downloads gigabytes and hits rate limits. - Generate the SBOM at build time and store it with the image (Day 14); rescan at night with a fresh database – new CVEs show up even without a new build.
- Gate on fixable findings from HIGH upward
(
--ignore-unfixedor--only-fixed), exceptions only with an expiry date and a ticket; severities differ between scanners. - Secret scanning belongs in the pre-commit hook and in the image gate – anything that was ever in a registry counts as compromised.
- docker scout: clarify data protection and licensing – SBOM data is matched on the Docker Scout platform; unsuitable for air-gapped environments.