Skip to content

Commit fa88f5d

Browse files
dhi: refresh troubleshoot & debug (#24658)
<!--Delete sections as needed --> ## Description Merged how-to/debug into troubleshoot to reduce left nav sprawl. Kept troubleshoot at top-level to align with other manuals. https://deploy-preview-24658--docsdocker.netlify.app/dhi/troubleshoot/ ## Related issues or tickets <!-- Related issues, pull requests, or Jira tickets --> ## Reviews <!-- Notes for reviewers here --> <!-- List applicable reviews (optionally @tag reviewers) --> - [ ] Editorial review --------- Signed-off-by: Craig Osterhout <craig.osterhout@docker.com> Co-authored-by: Allie Sadler <102604716+aevesdocker@users.noreply.github.com>
1 parent 2c74da9 commit fa88f5d

File tree

5 files changed

+129
-170
lines changed

5 files changed

+129
-170
lines changed

content/guides/dhi-backstage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ docker exec -it <container-id> sh
430430
OCI runtime exec failed: exec failed: unable to start container process: ...
431431
```
432432

433-
Use [Docker Debug](/dhi/how-to/debug/) if you need to troubleshoot a running distroless container.
433+
Use [Docker Debug](/dhi/troubleshoot/#general-debugging) if you need to troubleshoot a running distroless container.
434434

435435
> [!NOTE]
436436
>
@@ -480,4 +480,4 @@ Different scanners detect different issues. Running all three gives you the most
480480
- [Use the DHI CLI](/dhi/how-to/cli/) — manage DHI images, mirrors, and customizations from the command line.
481481
- [Migrate to DHI](/dhi/migration/) — for applications that work with standard DHI images without additional packages.
482482
- [Compare images](/dhi/how-to/explore/#compare-and-evaluate-images) — evaluate security improvements between your original and hardened images.
483-
- [Docker Debug](/dhi/how-to/debug/) — troubleshoot distroless containers that have no shell.
483+
- [Docker Debug](/dhi/troubleshoot/#general-debugging) — troubleshoot distroless containers that have no shell.

content/guides/dhi-openshift.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,6 @@ and use `COPY --chown` to transfer results.
620620

621621
- [Use an image in Kubernetes](/dhi/how-to/k8s/) — general DHI Kubernetes deployment guide.
622622
- [Customize an image](/dhi/how-to/customize/) — add packages to DHI images using Enterprise customization.
623-
- [Debug a container](/dhi/how-to/debug/) — troubleshoot distroless containers with Docker Debug (local development).
623+
- [Debug a container](/dhi/troubleshoot/#general-debugging) — troubleshoot distroless containers with Docker Debug (local development).
624624
- [Managing SCCs](https://docs.openshift.com/container-platform/4.14/authentication/managing-security-context-constraints.html) — Red Hat’s reference documentation on Security Context Constraints.
625625
- [Creating images for OpenShift](https://docs.openshift.com/container-platform/4.14/openshift_images/create-images.html) — Red Hat’s guidelines for building OpenShift-compatible container images.

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: How-tos
3-
description: Step-by-step guidance for working with Docker Hardened Images, from discovery to debugging.
3+
description: Step-by-step guidance for working with Docker Hardened Images, from discovery to governance.
44
weight: 20
55
params:
66
grid_discover:
@@ -63,17 +63,12 @@ params:
6363
description: Learn how to use image policies with Docker Scout for Docker Hardened Images.
6464
icon: policy
6565
link: /dhi/how-to/policies/
66-
grid_troubleshoot:
67-
- title: Debug a Docker Hardened Image
68-
description: Use Docker Debug to inspect a running container based on a hardened image without modifying it.
69-
icon: terminal
70-
link: /dhi/how-to/debug/
7166
---
7267

7368
This section provides practical, task-based guidance for working with Docker
7469
Hardened Images (DHIs). Whether you're evaluating DHIs for the first time or
7570
integrating them into a production CI/CD pipeline, these topics cover the key
76-
tasks across the adoption journey, from discovery to debugging.
71+
tasks across the adoption journey: discover, adopt, verify, and govern.
7772

7873
The topics are organized around the typical lifecycle of working with DHIs, but
7974
you can use them as needed based on your specific workflow.
@@ -111,11 +106,3 @@ Enforce policies to maintain security and compliance.
111106
{{< grid
112107
items="grid_govern"
113108
>}}
114-
115-
## Troubleshoot
116-
117-
Debug containers based on DHIs without modifying the image.
118-
119-
{{< grid
120-
items="grid_troubleshoot"
121-
>}}

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

Lines changed: 0 additions & 133 deletions
This file was deleted.

content/manuals/dhi/troubleshoot.md

Lines changed: 124 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,132 @@ title: Troubleshoot
33
description: Resolve common issues when building, running, or debugging Docker Hardened Images, such as non-root behavior, missing shells, and port access.
44
weight: 40
55
tags: [Troubleshooting]
6-
keywords: troubleshoot hardened image, docker debug container, non-root permission issue, missing shell error, no package manager
6+
keywords: troubleshoot hardened image, docker debug container, non-root permission issue, missing shell error, no package manager, debug, hardened images, DHI, troubleshooting, ephemeral container, docker debug, non-root containers, hardened container image, debug secure container
7+
aliases:
8+
- /dhi/how-to/debug/
79
---
810

9-
The following are common issues you may encounter while migrating to or using
10-
Docker Hardened Images (DHIs), along with recommended solutions.
11+
This page covers debugging techniques and common issues you may encounter while
12+
migrating to or using Docker Hardened Images (DHIs).
1113

1214
## General debugging
1315

14-
Docker Hardened Images are optimized for security and runtime performance. As
15-
such, they typically don't include a shell or standard debugging tools. The
16-
recommended way to troubleshoot containers built on DHIs is by using [Docker
17-
Debug](./how-to/debug.md).
16+
Docker Hardened Images prioritize minimalism and security, which means
17+
they intentionally leave out many common debugging tools (like shells or package
18+
managers). This makes direct troubleshooting difficult without introducing risk.
19+
To address this, you can use [Docker
20+
Debug](/reference/cli/docker/debug/), a secure workflow that
21+
temporarily attaches an ephemeral debug container to a running service or image
22+
without modifying the original image.
1823

19-
Docker Debug allows you to:
24+
This section shows how to debug Docker Hardened Images locally during development.
25+
With Docker Debug, you can also debug containers remotely using the `--host`
26+
option.
2027

21-
- Attach a temporary debug container to your existing container.
22-
- Use a shell and familiar tools such as `curl`, `ps`, `netstat`, and `strace`.
23-
- Install additional tools as needed in a writable, ephemeral layer that
24-
disappears after the session.
28+
### Use Docker Debug
2529

26-
## Permissions
30+
#### Step 1: Run a container from a Hardened Image
31+
32+
Start with a DHI-based container that simulates an issue:
33+
34+
```console
35+
$ docker run -d --name myapp dhi.io/python:3.13 python -c "import time; time.sleep(300)"
36+
```
37+
38+
This container doesn't include a shell or tools like `ps`, `top`, or `cat`.
39+
40+
If you try:
41+
42+
```console
43+
$ docker exec -it myapp sh
44+
```
45+
46+
You'll see:
47+
48+
```console
49+
exec: "sh": executable file not found in $PATH
50+
```
51+
52+
#### Step 2: Use Docker Debug to inspect the container
53+
54+
Use the `docker debug` command to attach a temporary, tool-rich debug container to the running instance.
55+
56+
```console
57+
$ docker debug myapp
58+
```
59+
60+
From here, you can inspect running processes, network status, or mounted files.
61+
62+
For example, to check running processes:
63+
64+
```console
65+
$ ps aux
66+
```
67+
68+
Type `exit` to leave the container when done.
69+
70+
### Alternative debugging approaches
71+
72+
In addition to using Docker Debug, you can also use the following approaches for
73+
debugging DHI containers.
74+
75+
#### Use the -dev variant
76+
77+
Docker Hardened Images offer a `-dev` variant that includes a shell
78+
and a package manager to install debugging tools. Simply replace the image tag
79+
with `-dev`:
80+
81+
```console
82+
$ docker run -it --rm dhi.io/python:3.13-dev sh
83+
```
84+
85+
Type `exit` to leave the container when done. Note that using the `-dev` variant
86+
increases the attack surface and it is not recommended as a runtime for
87+
production environments.
88+
89+
#### Mount debugging tools with image mounts
90+
91+
You can use the image mount feature to mount debugging tools into your container
92+
without modifying the base image.
93+
94+
##### Step 1: Run a container from a hardened image
95+
96+
Start with a DHI-based container that simulates an issue:
97+
98+
```console
99+
$ docker run -d --name myapp dhi.io/python:3.13 python -c "import time; time.sleep(300)"
100+
```
101+
102+
##### Step 2: Mount debugging tools into the container
103+
104+
Run a new container that mounts a tool-rich image (like `busybox`) into
105+
the running container's namespace:
106+
107+
```console
108+
$ docker run --rm -it --pid container:myapp \
109+
--mount type=image,source=busybox,destination=/dbg,ro \
110+
dhi.io/python:3.13 /dbg/bin/sh
111+
```
112+
113+
This mounts the BusyBox image at `/dbg`, giving you access to its tools while
114+
keeping your original container image unchanged. Since the hardened Python image
115+
doesn't include standard utilities, you need to use the full path to the mounted
116+
tools:
117+
118+
```console
119+
$ /dbg/bin/ls /
120+
$ /dbg/bin/ps aux
121+
$ /dbg/bin/cat /etc/os-release
122+
```
123+
124+
Type `exit` to leave the container when done.
125+
126+
## Common issues
127+
128+
The following are specific issues you may encounter when working with Docker
129+
Hardened Images, along with recommended solutions.
130+
131+
### Permissions
27132

28133
DHIs run as a nonroot user by default for enhanced security. This can result in
29134
permission issues when accessing files or directories. Ensure your application
@@ -34,7 +139,7 @@ To find out which user a DHI runs as, check the repository page for the image on
34139
Docker Hub. See [View image variant
35140
details](./how-to/explore.md#image-variant-details) for more information.
36141

37-
## Privileged ports
142+
### Privileged ports
38143

39144
Nonroot containers cannot bind to ports below 1024 by default. This is enforced
40145
by both the container runtime and the kernel (especially in Kubernetes and
@@ -45,7 +150,7 @@ port (1025 or higher). For example `docker run -p 80:8080 my-image` maps
45150
port 8080 in the container to port 80 on the host, allowing you to access it
46151
without needing root privileges.
47152

48-
## No shell
153+
### No shell
49154

50155
Runtime DHIs omit interactive shells like `sh` or `bash`. If your build or
51156
tooling assumes a shell is present (e.g., for `RUN` instructions), use a `dev`
@@ -56,10 +161,10 @@ To find out which shell, if any, a DHI has, check the repository page for the
56161
image on Docker Hub. See [View image variant
57162
details](./how-to/explore.md#image-variant-details) for more information.
58163

59-
Also, use [Docker Debug](./how-to/debug.md) when you need shell
60-
access to a running container.
164+
Also, use Docker Debug when you need shell access to a running container. For
165+
more details, see [General debugging](#general-debugging).
61166

62-
## Entry point differences
167+
### Entry point differences
63168

64169
DHIs may define different entry points compared to Docker Official Images (DOIs)
65170
or other community images.
@@ -68,7 +173,7 @@ To find out the ENTRYPOINT or CMD for a DHI, check the repository page for the
68173
image on Docker Hub. See [View image variant
69174
details](./how-to/explore.md#image-variant-details) for more information.
70175

71-
## No package manager
176+
### No package manager
72177

73178
Runtime Docker Hardened Images are stripped down for security and minimal attack
74179
surface. As a result, they don't include a package manager such as `apk` or

0 commit comments

Comments
 (0)