Skip to content

Commit 8b7793b

Browse files
dhi: add compare (#23637)
<!--Delete sections as needed --> ## Description Added how to compare images so that users can see a quick benefit of using DHI. - [Added compare topic](https://deploy-preview-23637--docsdocker.netlify.app/dhi/how-to/compare/) - [Added compare step to quickstart](https://deploy-preview-23637--docsdocker.netlify.app/dhi/get-started/#step-5-compare-with-the-other-images) - [Added what's next to migrate topic to point to compare](https://deploy-preview-23637--docsdocker.netlify.app/dhi/how-to/migrate/#whats-next) Additional changes: - [Updated the ordering of the how-to topics as they're growing](https://deploy-preview-23637--docsdocker.netlify.app/dhi/how-to/) - [Updated more info for "use" in quickstart to also point to k8 and helm topics](https://deploy-preview-23637--docsdocker.netlify.app/dhi/get-started/#step-4-pull-and-run-the-image) Will also incorporate compare into the image-specific docs. ## Related issues or tickets [ENGDOCS-3082](https://docker.atlassian.net/browse/ENGDOCS-3082) ## Reviews <!-- Notes for reviewers here --> <!-- List applicable reviews (optionally @tag reviewers) --> - [ ] Editorial review - [ ] Product review [ENGDOCS-3082]: https://docker.atlassian.net/browse/ENGDOCS-3082?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Signed-off-by: Craig Osterhout <[email protected]>
1 parent f372139 commit 8b7793b

File tree

8 files changed

+318
-25
lines changed

8 files changed

+318
-25
lines changed

content/manuals/dhi/get-started.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,56 @@ a simple Python command just like you would with any other Docker image:
117117
This starts a container from the `dhi-python:3.13` image and runs a simple
118118
Python script that prints `Hello from DHI`.
119119

120-
To dive deeper into using images see [Use a Docker Hardened Image](./how-to/use.md).
120+
To dive deeper into using images, see:
121+
122+
- [Use a Docker Hardened Image](./how-to/use.md) for general usage
123+
- [Use in Kubernetes](./how-to/k8s.md) for Kubernetes deployments
124+
- [Use a Helm chart](./how-to/helm.md) for deploying with Helm
125+
126+
## Step 5: Compare with the other images
127+
128+
You can quickly compare DHIs with other images to see the security
129+
improvements and differences. This comparison helps you understand the value of
130+
using hardened images.
131+
132+
Run the following command to see a summary comparison, replacing
133+
`<your-namespace>` with your organization's namespace:
134+
135+
```console
136+
$ docker scout compare <your-namespace>/dhi-python:3.13 \
137+
--to python:3.13 \
138+
--platform linux/amd64 \
139+
--ignore-unchanged \
140+
2>/dev/null | sed -n '/## Overview/,/^ ## /p' | head -n -1
141+
```
142+
143+
Example output:
144+
145+
```plaintext
146+
## Overview
147+
148+
│ Analyzed Image │ Comparison Image
149+
────────────────────┼───────────────────────────────────────────────────────┼───────────────────────────────────────────────
150+
Target │ docker/dhi-python:3.13 │ python:3.13
151+
digest │ c215e9da9f84 │ 7f48e892134c
152+
tag │ 3.13 │ 3.13
153+
platform │ linux/amd64 │ linux/amd64
154+
provenance │ https://github.com/docker-hardened-images/definitions │ https://github.com/docker-library/python.git
155+
│ 77a629b3d0db035700206c2a4e7ed904e5902ea8 │ 3f2d7e4c339ab883455b81a873519f1d0f2cd80a
156+
vulnerabilities │ 0C 0H 0M 0L │ 0C 1H 5M 141L 2?
157+
│ -1 -5 -141 -2 │
158+
size │ 35 MB (-377 MB) │ 412 MB
159+
packages │ 80 (-530) │ 610
160+
│ │
161+
```
162+
163+
This comparison shows that the Docker Hardened Image:
164+
165+
- Removes vulnerabilities: 1 high, 5 medium, 141 low, and 2 unspecified severity CVEs removed
166+
- Reduces size: From 412 MB down to 35 MB (91% reduction)
167+
- Minimizes packages: From 610 packages down to 80 (87% reduction)
168+
169+
To dive deeper into comparing images see [Compare Docker Hardened Images](./how-to/compare.md).
121170

122171
## What's next
123172

content/manuals/dhi/how-to/_index.md

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ title: How-tos
33
description: Step-by-step guidance for working with Docker Hardened Images, from discovery to debugging.
44
weight: 20
55
params:
6-
grid_howto:
6+
grid_discover:
77
- title: Explore Docker Hardened Images
88
description: Learn how to find and evaluate image repositories, variants, metadata, and attestations in the DHI catalog on Docker Hub.
99
icon: travel_explore
1010
link: /dhi/how-to/explore/
11+
grid_adopt:
1112
- title: Mirror a Docker Hardened Image repository
1213
description: Learn how to mirror an image into your organization's namespace and optionally push it to another private registry.
1314
icon: compare_arrows
@@ -36,6 +37,12 @@ params:
3637
description: Follow a step-by-step guide to update your Dockerfiles and adopt Docker Hardened Images for secure, minimal, and production-ready builds.
3738
icon: directions_run
3839
link: /dhi/how-to/migrate/
40+
grid_evaluate:
41+
- title: Compare Docker Hardened Images
42+
description: Learn how to compare Docker Hardened Images with other container images to evaluate security improvements and differences.
43+
icon: compare
44+
link: /dhi/how-to/compare/
45+
grid_verify:
3946
- title: Verify a Docker Hardened Image
4047
description: Use Docker Scout or cosign to verify signed attestations like SBOMs, provenance, and vulnerability data for Docker Hardened Images.
4148
icon: check_circle
@@ -44,40 +51,72 @@ params:
4451
description: Learn how to scan Docker Hardened Images for known vulnerabilities using Docker Scout, Grype, or Trivy.
4552
icon: bug_report
4653
link: /dhi/how-to/scan/
54+
grid_govern:
4755
- title: Enforce Docker Hardened Image usage with policies
4856
description: Learn how to use image policies with Docker Scout for Docker Hardened Images.
4957
icon: policy
5058
link: /dhi/how-to/policies/
59+
grid_troubleshoot:
5160
- title: Debug a Docker Hardened Image
5261
description: Use Docker Debug to inspect a running container based on a hardened image without modifying it.
5362
icon: terminal
5463
link: /dhi/how-to/debug/
5564
---
5665

57-
This section provides practical, step-by-step guidance for working with Docker
66+
This section provides practical, task-based guidance for working with Docker
5867
Hardened Images (DHIs). Whether you're evaluating DHIs for the first time or
59-
integrating them into a production CI/CD pipeline, these topics walk you
60-
through each phase of the adoption journey, from discovery to debugging.
68+
integrating them into a production CI/CD pipeline, these topics cover the key
69+
tasks across the adoption journey, from discovery to debugging.
6170

62-
To help you get started and stay secure, the topics are organized around the
63-
typical lifecycle of working with DHIs.
71+
The topics are organized around the typical lifecycle of working with DHIs, but
72+
you can use them as needed based on your specific workflow.
6473

65-
## Lifecycle flow
74+
Explore the topics below that match your current needs.
6675

67-
1. Explore available images and metadata in the DHI catalog.
68-
2. Mirror trusted images into your namespace or registry.
69-
3. Adopt DHIs in your workflows by pulling, using in development and CI, and
70-
migrating existing applications to use secure, minimal base images.
71-
4. Analyze images by verifying signatures, SBOMs, and provenance, and scanning
72-
for vulnerabilities.
73-
5. Enforce policies to maintain security and compliance.
74-
6. Debug containers based on DHIs without modifying the image.
76+
## Discover
7577

76-
Each of the following topics aligns with a step in this lifecycle, so you can progress
77-
confidently through exploration, implementation, and ongoing maintenance.
78+
Explore available images and metadata in the DHI catalog.
7879

79-
## Step-by-step topics
80+
{{< grid
81+
items="grid_discover"
82+
>}}
83+
84+
## Adopt
85+
86+
Mirror trusted images, customize as needed, and integrate into your workflows.
87+
88+
{{< grid
89+
items="grid_adopt"
90+
>}}
91+
92+
## Evaluate
93+
94+
Compare with other images to understand security improvements.
95+
96+
{{< grid
97+
items="grid_evaluate"
98+
>}}
99+
100+
## Verify
101+
102+
Check signatures, SBOMs, and provenance, and scan for vulnerabilities.
103+
104+
{{< grid
105+
items="grid_verify"
106+
>}}
107+
108+
## Govern
109+
110+
Enforce policies to maintain security and compliance.
111+
112+
{{< grid
113+
items="grid_govern"
114+
>}}
115+
116+
## Troubleshoot
117+
118+
Debug containers based on DHIs without modifying the image.
80119

81120
{{< grid
82-
items="grid_howto"
121+
items="grid_troubleshoot"
83122
>}}
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
---
2+
title: Compare Docker Hardened Images
3+
linktitle: Compare images
4+
description: Learn how to compare Docker Hardened Images with other container images to evaluate security improvements and differences.
5+
keywords: compare docker images, docker scout compare, image comparison, vulnerability comparison, security comparison
6+
weight: 40
7+
---
8+
9+
{{< summary-bar feature_name="Docker Hardened Images" >}}
10+
11+
Docker Hardened Images (DHIs) are designed to provide enhanced security,
12+
minimized attack surfaces, and production-ready foundations for your
13+
applications. Comparing a DHI to a standard image helps you understand the
14+
security improvements, package differences, and overall benefits of adopting
15+
hardened images.
16+
17+
This page explains how to use Docker Scout to compare a Docker Hardened Image
18+
with another image, such as a Docker Official Image (DOI) or a custom image, to
19+
evaluate differences in vulnerabilities, packages, and configurations.
20+
21+
## Compare images using Docker Scout
22+
23+
Docker Scout provides a built-in comparison feature that lets you analyze the
24+
differences between two images. This is useful for:
25+
26+
- Evaluating the security improvements when migrating from a standard image to a
27+
DHI
28+
- Understanding package and vulnerability differences between image variants
29+
- Assessing the impact of customizations or updates
30+
31+
### Basic comparison
32+
33+
To compare a Docker Hardened Image with another image, use the [`docker scout
34+
compare`](/reference/cli/docker/scout/compare/) command:
35+
36+
```console
37+
$ docker scout compare <your-namespace>/dhi-<image>:<tag> \
38+
--to <comparison-image>:<tag> \
39+
--platform <platform>
40+
```
41+
42+
For example, to compare a DHI Node.js image with the official Node.js image:
43+
44+
```console
45+
$ docker scout compare <your-namespace>/dhi-node:22-debian13 \
46+
--to node:22 \
47+
--platform linux/amd64
48+
```
49+
50+
This command provides a detailed comparison including:
51+
52+
- Vulnerability differences (CVEs added, removed, or changed)
53+
- Package differences (packages added, removed, or updated)
54+
- Overall security posture improvements
55+
56+
### Filter unchanged packages
57+
58+
To focus only on the differences and ignore unchanged packages, use the
59+
`--ignore-unchanged` flag:
60+
61+
```console
62+
$ docker scout compare <your-namespace>/dhi-node:22-debian13 \
63+
--to node:22 \
64+
--platform linux/amd64 \
65+
--ignore-unchanged
66+
```
67+
68+
This output highlights only the packages and vulnerabilities that differ between
69+
the two images, making it easier to identify the security improvements and
70+
changes.
71+
72+
### Show overview only
73+
74+
For a concise overview of the comparison results, you can extract just the
75+
overview section using standard shell tools:
76+
77+
```console
78+
$ docker scout compare <your-namespace>/dhi-node:22-debian13 \
79+
--to node:22 \
80+
--platform linux/amd64 \
81+
--ignore-unchanged \
82+
2>/dev/null | sed -n '/## Overview/,/^ ## /p' | head -n -1
83+
```
84+
85+
The result is a clean summary showing the key differences between the two
86+
images. Example output:
87+
88+
```console
89+
## Overview
90+
91+
│ Analyzed Image │ Comparison Image
92+
────────────────────┼───────────────────────────────────────────────────────┼─────────────────────────────────────────────
93+
Target │ docker/dhi-node:22-debian13 │ node:22
94+
digest │ 55d471f61608 │ 9ee3220f602f
95+
tag │ 22-debian13 │ 22
96+
platform │ linux/amd64 │ linux/amd64
97+
provenance │ https://github.com/docker-hardened-images/definitions │ https://github.com/nodejs/docker-node.git
98+
│ 9fe491f53122b84eebba81e13f20157c18c10de2 │ bf78d7603fbea92cd3652edb3b2edadd6f5a3fe8
99+
vulnerabilities │ 0C 0H 0M 0L │ 0C 1H 3M 153L 4?
100+
│ -1 -3 -153 -4 │
101+
size │ 41 MB (-367 MB) │ 408 MB
102+
packages │ 19 (-726) │ 745
103+
│ │
104+
```
105+
106+
## Interpret comparison results
107+
108+
The comparison output includes the following sections.
109+
110+
### Overview
111+
112+
The overview section provides high-level statistics about both images:
113+
114+
- Target and comparison image details (digest, tag, platform, provenance)
115+
- Vulnerability counts for each image
116+
- Size comparison
117+
- Package counts
118+
119+
Look for:
120+
121+
- Vulnerability reductions (negative numbers in the delta row)
122+
- Size reductions showing storage efficiency
123+
- Package count reductions indicating a minimal attack surface
124+
125+
### Environment Variables
126+
127+
The environment variables section shows environment variables that differ between
128+
the two images, prefixed with `+` for added or `-` for removed.
129+
130+
Look for:
131+
132+
- Removed environment variables that may have been necessary for your specific use-case
133+
134+
### Labels
135+
136+
The labels section displays labels that differ between the two images, prefixed
137+
with `+` for added or `-` for removed.
138+
139+
### Packages and Vulnerabilities
140+
141+
The packages and vulnerabilities section lists all package differences and their
142+
associated security vulnerabilities. Packages are prefixed with:
143+
144+
- `-` for packages removed from the target image (not present in the compared image)
145+
- `+` for packages added to the target image (not present in the base image)
146+
- `` for packages upgraded in the target image
147+
- `` for packages downgraded in the target image
148+
149+
For packages with associated vulnerabilities, the CVEs are listed with their
150+
severity levels and identifiers.
151+
152+
Look for:
153+
154+
- Removed packages and vulnerabilities: Indicates a reduced attack surface in the DHI
155+
- Added packages: May indicate DHI-specific tooling or dependencies
156+
- Upgraded packages: Shows version updates that may include security fixes
157+
158+
## When to compare images
159+
160+
### Evaluate migration benefits
161+
162+
Before migrating from a Docker Official Image to a DHI, compare them to
163+
understand the security improvements. For example:
164+
165+
```console
166+
$ docker scout compare <your-namespace>/dhi-python:3.13 \
167+
--to python:3.13 \
168+
--platform linux/amd64 \
169+
--ignore-unchanged
170+
```
171+
172+
This helps justify the migration by showing concrete vulnerability reductions
173+
and package minimization.
174+
175+
### Assess customization impact
176+
177+
After customizing a DHI, compare the customized version with the original to
178+
ensure you haven't introduced new vulnerabilities. For example:
179+
180+
```console
181+
$ docker scout compare <your-namespace>/dhi-python:3.13-custom \
182+
--to <your-namespace>/dhi-python:3.13 \
183+
--platform linux/amd64
184+
```
185+
186+
### Track updates over time
187+
188+
Compare different versions of the same DHI to see what changed between releases. For example:
189+
190+
```console
191+
$ docker scout compare <your-namespace>/dhi-node:22-debian13 \
192+
--to <your-namespace>/dhi-node:20-debian12 \
193+
--platform linux/amd64 \
194+
--ignore-unchanged
195+
```

content/manuals/dhi/how-to/helm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Use a Docker Hardened Image chart
33
linktitle: Use a Helm chart
44
description: Learn how to use a Docker Hardened Image chart.
55
keywords: use hardened image, helm, k8s, kubernetes, dhi chart, chart
6-
weight: 36
6+
weight: 32
77
params:
88
sidebar:
99
badge:

content/manuals/dhi/how-to/k8s.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Use a Docker Hardened Image in Kubernetes
33
linktitle: Use an image in Kubernetes
44
description: Learn how to use Docker Hardened Images in Kubernetes deployments.
55
keywords: use hardened image, kubernetes, k8s
6-
weight: 35
6+
weight: 31
77
---
88

99
{{< summary-bar feature_name="Docker Hardened Images" >}}

content/manuals/dhi/how-to/manage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Manage Docker Hardened Images
33
linktitle: Manage images
44
description: Learn how to manage your mirrored and customized Docker Hardened Images in your organization.
55
keywords: manage docker hardened images, custom hardened images
6-
weight: 45
6+
weight: 35
77
---
88

99
{{< summary-bar feature_name="Docker Hardened Images" >}}

0 commit comments

Comments
 (0)