Interview's MateDocker
Interview's Mate

Docker

Compose · Networking · Security · Ops

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Docker topics
Lesson 115/ 160
06. Docker Security & Hardening

Software Bill of Materials (SBOM) Generation (syft, docker sbom)

Generate SBOMs so you know exactly which packages ship in each image.

IntermediateSBOM · syft3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

Generate an inventory in the release job so vulnerability correlation, licensing and incident response refer to what was actually shipped.

Think of it like…

The SBOM is the bill of materials in the shipped machine’s serial folder: it names parts and supplier versions even when no recall has been announced.

Where you’ve seen it

In practice, syft packages ghcr.io/acme/api@sha256:deadbeef -o spdx-json=api.spdx.json; cosign attest --type spdx api@sha256:deadbeef --predicate api.spdx.json is the concrete move for this job: generate SBOMs so you know exactly which packages ship in each image. The release is not accepted until jq SPDXID/api package count and attest/verify the digest binding in a fresh consumer workflow confirms the result.

Words you’ll hear

SBOM
The implementation control in syft packages ghcr.io/acme/api@sha256:deadbeef -o spdx-json=api.spdx.json; cosign attest --type spdx api@sha256:deadbeef --predicate api.spdx.json for generate SBOMs so you know exactly which packages ship in each image.
syft
The result to observe with jq SPDXID/api package count and attest/verify the digest binding in a fresh consumer workflow, rather than infer from a successful command alone.
Inventory
The production boundary exposed when making an SBOM for source files and attaching it to a different rebuilt image digest, or storing it with no retention and signer identity.

Visual diagram

Loading interactive diagram

Theory & deep dive

SBOM control path

The concrete mechanism is syft packages ghcr.io/acme/api@sha256:deadbeef -o spdx-json=api.spdx.json; cosign attest --type spdx api@sha256:deadbeef --predicate api.spdx.json. The observable result is jq SPDXID/api package count and attest/verify the digest binding in a fresh consumer workflow; if those disagree, inspect the runtime evidence before changing unrelated settings.

Generate SBOMs so you know exactly which packages ship in each image. Keep SBOM, syft and Inventory in the same deployment record so the intent and the observed state cannot drift apart.

Concrete SBOM setup

syft packages ghcr.io/acme/api@sha256:deadbeef -o spdx-json=api.spdx.json; cosign attest --type spdx api@sha256:deadbeef --predicate api.spdx.json

Key takeaway: Prove syft with jq SPDXID/api package count and attest/verify the digest binding in a fresh consumer workflow, not with command success alone.

Inventory failure boundary

A scan result is not an SBOM, and an application manifest is not enough to account for base-image packages. Directory source inventories and final image inventories differ; generated SBOMs can also omit packages from unsupported or unpackaged binaries. The narrow failure to design for is making an SBOM for source files and attaching it to a different rebuilt image digest, or storing it with no retention and signer identity.

Accept this compromise explicitly: SPDX is broad for tooling/legal use; CycloneDX is rich for software security, and signed attestations prevent silent substitution. The controlled check-jq SPDXID/api package count and attest/verify the digest binding in a fresh consumer workflow-also identifies the point where a different design is safer.

Deliberate failure test

Exercise this failure safely: making an SBOM for source files and attaching it to a different rebuilt image digest, or storing it with no retention and signer identity.

Key takeaway: SPDX is broad for tooling/legal use; CycloneDX is rich for software security, and signed attestations prevent silent substitution.

How it works, step by step

Step 1 of 4
Design

1. State the boundary

Write down why the workload needs this: A scan result is not an SBOM, and an application manifest is not enough to account for base-image packages. Directory source inventories and final image inventories differ; generated SBOMs can also omit packages from unsupported or unpackaged binaries.

Generate an inventory in the release job so vulnerability correlation, licensing and incident response refer to what was actually shipped.
Key numbers at this step
Intent
SBOM

When to use it & trade-offs

What it is

An SBOM records package and file/component relationships from an image. syft or Docker tooling can emit SPDX/CycloneDX JSON for operating-system packages, language dependencies and nested archives, and the artifact should be tied to the exact image digest.

Why it matters: A scan result is not an SBOM, and an application manifest is not enough to account for base-image packages. Directory source inventories and final image inventories differ; generated SBOMs can also omit packages from unsupported or unpackaged binaries.

When to reach for it

  • The fit is strongest for this job: generate SBOMs so you know exactly which packages ship in each image. Pair it with jq SPDXID/api package count and attest/verify the digest binding in a fresh consumer workflow in the runbook.
  • Production SBOM changes should make syft observable through syft packages ghcr.io/acme/api@sha256:deadbeef -o spdx-json=api.spdx.json; cosign attest --type spdx api@sha256:deadbeef --predicate api.spdx.json, rather than trusting the runtime default.
  • Keep a rollback example for the case where making an SBOM for source files and attaching it to a different rebuilt image digest, or storing it with no retention and signer identity.

When to avoid or be careful

  • Do not accept command success while the system can still fail by making an SBOM for source files and attaching it to a different rebuilt image digest, or storing it with no retention and signer identity.
  • Avoid erasing Inventory protection merely to dodge this cost: “SPDX is broad for tooling/legal use; CycloneDX is rich for software security, and signed attestations prevent silent substitution”.
  • Do not replace the evidence path-jq SPDXID/api package count and attest/verify the digest binding in a fresh consumer workflow-with a screenshot or a mutable tag.

syft packages ghcr.io/acme/api@sha256:deadbeef -o spdx-json=api.spdx.json; cosign attest --type spdx api@sha256:deadbeef --predicate api.spdx.json: practical choices

Explicit SBOM
Best for: Generate SBOMs so you know exactly which packages ship in each image, with a reviewed runbook.

Strengths: An SBOM records package and file/component relationships from an image. syft or Docker tooling can emit SPDX/CycloneDX JSON for operating-system packages, language dependencies and nested archives, and the artifact should be tied to the exact image digest.

Watch out: SPDX is broad for tooling/legal use; CycloneDX is rich for software security, and signed attestations prevent silent substitution.

Ambient default
Best for: Short-lived syft experiments with low blast radius.

Strengths: It can begin with syft packages ghcr.io/acme/api@sha256:deadbeef -o spdx-json=api.spdx.json; cosign attest --type spdx api@sha256:deadbeef --predicate api.spdx.json and fewer surrounding controls.

Watch out: It silently accepts making an SBOM for source files and attaching it to a different rebuilt image digest, or storing it with no retention and signer identity, which makes the result hard to reproduce after promotion.

Managed Inventory
Best for: Teams that centralize Inventory policy across many workloads.

Strengths: A scan result is not an SBOM, and an application manifest is not enough to account for base-image packages. Directory source inventories and final image inventories differ; generated SBOMs can also omit packages from unsupported or unpackaged binaries.

Watch out: The platform adds an ownership and debugging layer; retain jq SPDXID/api package count and attest/verify the digest binding in a fresh consumer workflow as the direct check.

Interview signals & numbers to know

When this topic comes up

  • syft packages ghcr.io/acme/api@sha256:deadbeef -o spdx-json=api.spdx.json; cosign attest --type spdx api@sha256:deadbeef --predicate api.spdx.json
  • jq SPDXID/api package count and attest/verify the digest binding in a fresh consumer workflow
  • Failure signature: making an SBOM for source files and attaching it to a different rebuilt image digest, or storing it with no retention and signer identity
  • Trade-off: SPDX is broad for tooling/legal use; CycloneDX is rich for software security, and signed attestations prevent silent substitution.

Benchmarks & rules of thumb

2 common formats -
SPDX and CycloneDX
1 exact digest -
the SBOM inventory must reference
0 interpretation -
SBOM presence does not itself fix a vulnerability

Common mistakes & follow-ups

Common interview mistakes

  • Treating a successful syft packages ghcr.io/acme/api@sha256:deadbeef -o spdx-json=api.spdx.json; cosign attest --type spdx api@sha256:deadbeef --predicate api.spdx.json as proof and skipping jq SPDXID/api package count and attest/verify the digest binding in a fresh consumer workflow.
  • Making an SBOM for source files and attaching it to a different rebuilt image digest, or storing it with no retention and signer identity
  • Optimizing SBOM without accepting that sPDX is broad for tooling/legal use; CycloneDX is rich for software security, and signed attestations prevent silent substitution.

Likely interviewer follow-ups

  • Why does syft packages ghcr.io/acme/api@sha256:deadbeef -o spdx-json=api.spdx.json; cosign attest --type spdx api@sha256:deadbeef --predicate api.spdx.json address SBOM here rather than through application code?
  • How would you distinguish healthy syft from the failure “making an SBOM for source files and attaching it to a different rebuilt image digest, or storing it with no retention and signer identity” using jq SPDXID/api package count and attest/verify the digest binding in a fresh consumer workflow?
  • When would this trade-off-“SPDX is broad for tooling/legal use; CycloneDX is rich for software security, and signed attestations prevent silent substitution”-justify a different Inventory design?
Interview tip: Give one concrete operation-syft packages ghcr.io/acme/api@sha256:deadbeef -o spdx-json=api.spdx.json; cosign attest --type spdx api@sha256:deadbeef --predicate api.spdx.json-and one proof-jq SPDXID/api package count and attest/verify the digest binding in a fresh consumer workflow. Then name the boundary: making an SBOM for source files and attaching it to a different rebuilt image digest, or storing it with no retention and signer identity.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Software Bill of Materials (SBOM) Generation (syft, docker sbom) with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Image Vulnerability Scanning (docker scout, Trivy, Grype)
Next topic
Image Signing, Verification & Supply Chain Security (Cosign, Notary)