@@ -3,27 +3,132 @@ title: Troubleshoot
33description : Resolve common issues when building, running, or debugging Docker Hardened Images, such as non-root behavior, missing shells, and port access.
44weight : 40
55tags : [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
28133DHIs run as a nonroot user by default for enhanced security. This can result in
29134permission 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
34139Docker Hub. See [ View image variant
35140details] ( ./how-to/explore.md#image-variant-details ) for more information.
36141
37- ## Privileged ports
142+ ### Privileged ports
38143
39144Nonroot containers cannot bind to ports below 1024 by default. This is enforced
40145by 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
45150port 8080 in the container to port 80 on the host, allowing you to access it
46151without needing root privileges.
47152
48- ## No shell
153+ ### No shell
49154
50155Runtime DHIs omit interactive shells like ` sh ` or ` bash ` . If your build or
51156tooling 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
56161image on Docker Hub. See [ View image variant
57162details] ( ./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
64169DHIs may define different entry points compared to Docker Official Images (DOIs)
65170or other community images.
@@ -68,7 +173,7 @@ To find out the ENTRYPOINT or CMD for a DHI, check the repository page for the
68173image on Docker Hub. See [ View image variant
69174details] ( ./how-to/explore.md#image-variant-details ) for more information.
70175
71- ## No package manager
176+ ### No package manager
72177
73178Runtime Docker Hardened Images are stripped down for security and minimal attack
74179surface. As a result, they don't include a package manager such as ` apk ` or
0 commit comments