|
| 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` command: |
| 35 | + |
| 36 | +```console |
| 37 | +$ docker scout compare <your-namespace>/dhi-<image>:<tag> --to <comparison-image>:<tag> --platform <platform> |
| 38 | +``` |
| 39 | + |
| 40 | +For example, to compare a DHI Node.js image with the official Node.js image: |
| 41 | + |
| 42 | +```console |
| 43 | +$ docker scout compare <your-namespace>/dhi-node:22-debian13 --to node:22 --platform linux/amd64 |
| 44 | +``` |
| 45 | + |
| 46 | +This command provides a detailed comparison including: |
| 47 | + |
| 48 | +- Vulnerability differences (CVEs added, removed, or changed) |
| 49 | +- Package differences (packages added, removed, or updated) |
| 50 | +- Overall security posture improvements |
| 51 | + |
| 52 | +For more details on the `docker scout compare` command and all available options, |
| 53 | +see the [Docker Scout compare reference](/reference/cli/docker/scout/compare/). |
| 54 | + |
| 55 | +### Filter unchanged packages |
| 56 | + |
| 57 | +To focus only on the differences and ignore unchanged packages, use the |
| 58 | +`--ignore-unchanged` flag: |
| 59 | + |
| 60 | +```console |
| 61 | +$ docker scout compare <your-namespace>/dhi-node:22-debian13 --to node:22 --platform linux/amd64 --ignore-unchanged |
| 62 | +``` |
| 63 | + |
| 64 | +This output highlights only the packages and vulnerabilities that differ between |
| 65 | +the two images, making it easier to identify the security improvements and |
| 66 | +changes. |
| 67 | + |
| 68 | +### Show overview only |
| 69 | + |
| 70 | +For a concise overview of the comparison results, you can extract just the |
| 71 | +overview section using standard shell tools: |
| 72 | + |
| 73 | +```console |
| 74 | +$ docker scout compare <your-namespace>/dhi-node:22-debian13 --to node:22 --platform linux/amd64 --ignore-unchanged 2>/dev/null | sed -n '/## Overview/,/^ ## /p' | head -n -1 |
| 75 | +``` |
| 76 | + |
| 77 | +The result is a clean summary showing the key differences between the two |
| 78 | +images. Example output: |
| 79 | + |
| 80 | +```console |
| 81 | + ## Overview |
| 82 | + |
| 83 | + │ Analyzed Image │ Comparison Image |
| 84 | + ────────────────────┼───────────────────────────────────────────────────────┼───────────────────────────────────────────── |
| 85 | + Target │ docker/dhi-node:22-debian13 │ node:22 |
| 86 | + digest │ 55d471f61608 │ 9ee3220f602f |
| 87 | + tag │ 22-debian13 │ 22 |
| 88 | + platform │ linux/amd64 │ linux/amd64 |
| 89 | + provenance │ https://github.com/docker-hardened-images/definitions │ https://github.com/nodejs/docker-node.git |
| 90 | + │ 9fe491f53122b84eebba81e13f20157c18c10de2 │ bf78d7603fbea92cd3652edb3b2edadd6f5a3fe8 |
| 91 | + vulnerabilities │ 0C 0H 0M 0L │ 0C 1H 3M 153L 4? |
| 92 | + │ -1 -3 -153 -4 │ |
| 93 | + size │ 41 MB (-367 MB) │ 408 MB |
| 94 | + packages │ 19 (-726) │ 745 |
| 95 | + │ │ |
| 96 | +``` |
| 97 | + |
| 98 | +## Interpret comparison results |
| 99 | + |
| 100 | +The comparison output includes the following sections. |
| 101 | + |
| 102 | +### Overview |
| 103 | + |
| 104 | +The overview section provides high-level statistics about both images: |
| 105 | + |
| 106 | +- Target and comparison image details (digest, tag, platform, provenance) |
| 107 | +- Vulnerability counts for each image |
| 108 | +- Size comparison |
| 109 | +- Package counts |
| 110 | + |
| 111 | +Look for: |
| 112 | + |
| 113 | +- Vulnerability reductions (negative numbers in the delta row) |
| 114 | +- Size reductions showing storage efficiency |
| 115 | +- Package count reductions indicating a minimal attack surface |
| 116 | + |
| 117 | +### Environment Variables |
| 118 | + |
| 119 | +The environment variables section shows environment variables that differ between |
| 120 | +the two images, prefixed with `+` for added or `-` for removed. |
| 121 | + |
| 122 | +Look for: |
| 123 | + |
| 124 | +- Removed environment variables that may have been necessary for your specific use-case |
| 125 | + |
| 126 | +### Labels |
| 127 | + |
| 128 | +The labels section displays labels that differ between the two images, prefixed |
| 129 | +with `+` for added or `-` for removed. |
| 130 | + |
| 131 | +### Packages and Vulnerabilities |
| 132 | + |
| 133 | +The packages and vulnerabilities section lists all package differences and their |
| 134 | +associated security vulnerabilities. Packages are prefixed with: |
| 135 | + |
| 136 | +- `-` for packages removed from the target image (not present in the compared image) |
| 137 | +- `+` for packages added to the target image (not present in the base image) |
| 138 | +- `↑` for packages upgraded in the target image |
| 139 | +- `↓` for packages downgraded in the target image |
| 140 | + |
| 141 | +For packages with associated vulnerabilities, the CVEs are listed with their |
| 142 | +severity levels and identifiers. |
| 143 | + |
| 144 | +Look for: |
| 145 | + |
| 146 | +- Removed packages and vulnerabilities: Indicates a reduced attack surface in the DHI |
| 147 | +- Added packages: May indicate DHI-specific tooling or dependencies |
| 148 | +- Upgraded packages: Shows version updates that may include security fixes |
| 149 | + |
| 150 | +## When to compare images |
| 151 | + |
| 152 | +### Evaluate migration benefits |
| 153 | + |
| 154 | +Before migrating from a Docker Official Image to a DHI, compare them to |
| 155 | +understand the security improvements. For example: |
| 156 | + |
| 157 | +```console |
| 158 | +$ docker scout compare <your-namespace>/dhi-python:3.13 --to python:3.13 --platform linux/amd64 --ignore-unchanged |
| 159 | +``` |
| 160 | + |
| 161 | +This helps justify the migration by showing concrete vulnerability reductions |
| 162 | +and package minimization. |
| 163 | + |
| 164 | +### Assess customization impact |
| 165 | + |
| 166 | +After customizing a DHI, compare the customized version with the original to |
| 167 | +ensure you haven't introduced new vulnerabilities. For example: |
| 168 | + |
| 169 | +```console |
| 170 | +$ docker scout compare <your-namespace>/dhi-python:3.13-custom --to <your-namespace>/dhi-python:3.13 --platform linux/amd64 |
| 171 | +``` |
| 172 | + |
| 173 | +### Track updates over time |
| 174 | + |
| 175 | +Compare different versions of the same DHI to see what changed between releases. For example: |
| 176 | + |
| 177 | +```console |
| 178 | +$ docker scout compare <your-namespace>/dhi-node:22-debian13 --to <your-namespace>/dhi-node:20-debian12 --platform linux/amd64 --ignore-unchanged |
| 179 | +``` |
0 commit comments