@@ -3,7 +3,7 @@ title: Kubernetes Ephemeral Containers and kubectl debug Command
33published : true
44description : Deep Diving Kubernetes Ephemeral Containers and kubectl debug Command
55tags : kubernetes
6- cover_image : ' https://raw.githubusercontent.com/AliMehraji /Documents/refs/heads/main/posts/assets/k8s-debug-ctr-in-pod-shared-ns.webP'
6+ cover_image : ' https://raw.githubusercontent.com/cod3mas0n /Documents/refs/heads/main/posts/assets/k8s-debug-ctr-in-pod-shared-ns.webP'
77canonical_url : null
88id : 2795240
99date : ' 2025-08-23T22:29:01Z'
@@ -82,6 +82,10 @@ error: Internal error occurred: Internal error occurred: error executing command
8282
8383# ## `kubectl debug`
8484
85+ 
86+
87+ 
88+
8589` ` ` bash
8690POD_NAME=$(kubectl get pods -l app=distroless-nginx -o jsonpath='{.items[0].metadata.name}')
8791kubectl debug -it -c debugger --image=busybox ${POD_NAME}
@@ -188,6 +192,20 @@ Don't forget to clean up the debugging Pod when you're finished with it:
188192kubectl delete pod node-debugger-debian-11-wrjhs
189193` ` `
190194
195+ # ## Sidecar container via Docker
196+
197+ 
198+
199+ How `docker exec` and [`cdebug`](https://github.com/iximiuz/cdebug) works ?
200+
201+ How to reproduce the docker exec-like functionality with the docker run command by starting a new container in the target container's namespaces :
202+
203+ ` ` ` bash
204+ docker run -itd --name sidecar --pid container:target --ipc container:target --network container:target alpine sh
205+ ` ` `
206+
207+ [Docker Debug](https://docs.docker.com/reference/cli/docker/debug/)
208+
191209# # Resources
192210
193211- [Docker Containers vs. Kubernetes Pods - Taking a Deeper Look][ix-posts-containers-vs-pods]
@@ -229,8 +247,8 @@ kubectl delete pod node-debugger-debian-11-wrjhs
229247[ephemeral-ctrs-feature-request] : https://github.com/kubernetes/enhancements/issues/277
230248[FR : New kubectl command]: https://github.com/kubernetes/kubernetes/issues/45922
231249
232- [shared-ns-img] : https://raw.githubusercontent.com/AliMehraji /Documents/refs/heads/main/posts/assets/k8s-debug-ctr-in-pod-shared-ns.webP
233- [after-ns-shared] : https://raw.githubusercontent.com/AliMehraji /Documents/refs/heads/main/posts/assets/ctr-in-pod-shared-pid-ns.WebP
250+ [shared-ns-img] : https://raw.githubusercontent.com/cod3mas0n /Documents/refs/heads/main/posts/assets/k8s-debug-ctr-in-pod-shared-ns.webP
251+ [after-ns-shared] : https://raw.githubusercontent.com/cod3mas0n /Documents/refs/heads/main/posts/assets/ctr-in-pod-shared-pid-ns.WebP
234252
235253[debugging-profiles] : https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#debugging-profiles
236254
0 commit comments