@@ -14,12 +14,13 @@ Debug](../../../reference/cli/docker/debug.md), a secure workflow that
1414temporarily attaches an ephemeral debug container to a running service or image
1515without modifying the original image.
1616
17- This guide shows how to debug Docker Hardened Images locally during
18- development. You can also debug containers remotely using the ` --host ` option.
17+ This guide shows how to debug Docker Hardened Images locally during development.
18+ With Docker Debug, you can also debug containers remotely using the ` --host `
19+ option.
1920
20- The following example uses a mirrored ` python:3.13 ` image, but the same steps apply to any image.
21+ ## Use Docker Debug
2122
22- ## Step 1: Run a container from a Hardened Image
23+ ### Step 1: Run a container from a Hardened Image
2324
2425Start with a DHI-based container that simulates an issue:
2526
@@ -41,7 +42,7 @@ You'll see:
4142exec: "sh": executable file not found in $PATH
4243```
4344
44- ## Step 2: Use Docker Debug to inspect the container
45+ ### Step 2: Use Docker Debug to inspect the container
4546
4647Use the ` docker debug ` command to attach a temporary, tool-rich debug container to the running instance.
4748
@@ -57,17 +58,75 @@ For example, to check running processes:
5758$ ps aux
5859```
5960
60- Exit the debug session with:
61+ Type ` exit ` to leave the container when done.
62+
63+ ## Alternative debugging approaches
64+
65+ In addition to using Docker Debug, you can also use the following approaches for
66+ debugging DHI containers.
67+
68+ ### Use the -dev variant
69+
70+ Docker Hardened Images offer a ` -dev ` variant that includes a shell
71+ and a package manager to install debugging tools. Simply replace the image tag
72+ with ` -dev ` :
73+
74+ ``` console
75+ $ docker run -it --rm dhi.io/python:3.13-dev sh
76+ ```
77+
78+ Type ` exit ` to leave the container when done. Note that using the ` -dev ` variant
79+ increases the attack surface and it is not recommended as a runtime for
80+ production environments.
81+
82+ ### Mount debugging tools with image mounts
83+
84+ You can use the image mount feature to mount debugging tools into your container
85+ without modifying the base image.
86+
87+ #### Step 1: Run a container from a Hardened Image
88+
89+ Start with a DHI-based container that simulates an issue:
6190
6291``` console
63- $ exit
92+ $ docker run -d --name myapp dhi.io/python:3.13 python -c " import time; time.sleep(300) "
6493```
6594
95+ #### Step 2: Mount debugging tools into the container
96+
97+ Run a new container that mounts a tool-rich image (like ` busybox ` ) into
98+ the running container's namespace:
99+
100+ ``` console
101+ $ docker run --rm -it --pid container:myapp \
102+ --mount type=image,source=busybox,destination=/dbg,ro \
103+ dhi.io/python:3.13 /dbg/bin/sh
104+ ```
105+
106+ This mounts the BusyBox image at ` /dbg ` , giving you access to its tools while
107+ keeping your original container image unchanged. Since the hardened Python image
108+ doesn't include standard utilities, you need to use the full path to the mounted
109+ tools:
110+
111+ ``` console
112+ $ /dbg/bin/ls /
113+ $ /dbg/bin/ps aux
114+ $ /dbg/bin/cat /etc/os-release
115+ ```
116+
117+ Type ` exit ` to leave the container when done.
118+
66119## What's next
67120
68- Docker Debug helps you troubleshoot hardened containers without compromising the
69- integrity of the original image. Because the debug container is ephemeral and
70- separate, it avoids introducing security risks into production environments.
121+ This guide covered three approaches for debugging Docker Hardened Images:
122+
123+ - Docker Debug: Attach an ephemeral debug container without modifying the original image
124+ - ` -dev ` variants: Use development images that include debugging tools
125+ - Image mount: Mount tool-rich images like BusyBox to access debugging utilities
126+
127+ Each method helps you troubleshoot hardened containers while maintaining
128+ security. Docker Debug and image mounts avoid modifying your production images,
129+ while ` -dev ` variants provide convenience during development.
71130
72131If you encounter issues related to permissions, ports, missing shells, or
73132package managers, see [ Troubleshoot Docker Hardened Images] ( ../troubleshoot.md )
0 commit comments