Sub topic 2
What an SBOM Is and What It Lists
This chapter assumes you can write a basic Dockerfile, push an image to a registry, and read JSON with jq. It covers what a Software Bill of Materials (SBOM) contains and what the BuildKit scanner puts in one. Later chapters cover generating and storing it in detail.
What an SBOM Is
A Software Bill of Materials (SBOM) is a machine-readable inventory of the components inside a piece of software. It works like an ingredient list. For a container image, the components are mostly operating system packages and application libraries.
An SBOM answers one question: what is in this image? That lets you act on a new vulnerability report without unpacking images by hand. If a flaw is announced in a library, you search your SBOMs for that library and its version. You get a list of affected images without rescanning every one.
What an SBOM Lists
Each entry describes one component. A typical entry has these fields:
| Field | Meaning | Example |
|---|---|---|
| Name | The package or library name | `curl` |
| Version | The exact installed version | `8.9.1-r0` |
| Package URL (purl) | A standard identifier that includes the ecosystem | `pkg:apk/alpine/[email protected]` |
| License | The declared license, when known | `MIT` |
| Location | The file path where the scanner found it | `/lib/apk/db/installed` |
| Relationships | Which component depends on or contains another | `curl` depends on `libcurl` |
The document also has metadata: which tool created it, when, and which image it describes. Treat the field values above as illustrations. Real values depend on the base image and the package index at build time.
SBOM Formats
Two formats dominate: SPDX and CycloneDX. BuildKit's default scanner, Docker Buildkit Syft scanner, produces SPDX JSON. Other scanners can be configured to produce other formats. The format is a property of the scanner you choose, not of the image.
A Worked Example
Take this Dockerfile. It installs one extra package on top of Alpine.
FROM alpine:3.20
RUN apk add --no-cache curl
CMD ["curl", "--version"]The SBOM for the built image lists more than curl. It contains:
- The base packages that ship with Alpine, such as
busyboxandmusl. curlitself.- The libraries
curlpulls in as dependencies, such aslibcurl,nghttp2-libs, andlibssl3.
You did not ask for the dependencies by name. The scanner finds them because they appear in the package database inside the image. That is the main value of an SBOM: it shows the transitive dependencies you never typed.
After you push the image with an SBOM (covered in a later chapter), you can read it back like this:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .SBOM }}' | jq .The output is JSON. Look for the package list and the document metadata near the top.
flowchart TDThe diagram block below shows the flow instead.
What an SBOM Does Not Tell You
An SBOM is a list, not a verdict. Keep these limits in mind:
- It does not say whether a component is vulnerable. You compare the list against a vulnerability database.
- It only lists what the scanner can detect. Software copied in as a bare binary, with no package metadata, may be missing.
- It is only as trustworthy as the process that made it. An unsigned SBOM can be replaced. Later chapters return to this.
Common Errors
- Reading
.SBOMfrom an image built without one. The command prints nothing useful, because no SBOM was attached at build time. - Expecting a package that is not in a package manager. A file downloaded with
curlorADDduring the build often does not appear. - Treating the SBOM as a vulnerability report. It lists components only.
Exercise
A Dockerfile runs apk add --no-cache curl on Alpine. The SBOM lists libcurl, which you never wrote in the Dockerfile. Why is it there, and why is that useful?
Show answer
libcurl is a dependency that curl needs, so the package manager installed it, and it appears in the image's package database that the scanner reads. This is useful because vulnerabilities often sit in transitive dependencies, and the SBOM lets you find them without knowing the full dependency tree yourself.