Kubernetes Debugging Cheat Sheet/Create a copy of a pod for debugging

Duplicate a pod and add a debug container or different command.

Section: Logs, Exec, and Ephemeral Debugging

Create a copy of a pod for debugging

bash
bash
kubectl debug <pod> -n <namespace> --copy-to=<pod>-debug --container=debugger --image=busybox:1.36 -it

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Logs, Exec, and Ephemeral Debugging
Attach an ephemeral debug container
Launch a temporary debugging container in an existing pod.
OpenIn sheetbashsame section
Read pod logs
Print logs from a single-container pod.
OpenIn sheetbashsame section
Read logs from a specific container
Required for multi-container pods.
OpenIn sheetbashsame section
Stream logs
Follow logs live while reproducing an issue.
OpenIn sheetbashsame section
Read previous container logs
Useful after restarts or CrashLoopBackOff.
OpenIn sheetbashsame section
Read logs for pods matching a label
Aggregate logs from a workload set.
OpenIn sheetbashsame section