← All notes

kubectl debug adds an ephemeral container to a running Pod for troubleshooting

Answer: Run kubectl debug -it <pod> --image=busybox:1.28 --target=<container> to add an ephemeral container to the Pod and attach to it. Use them for interactive troubleshooting when a container has crashed or a container image doesn't include debugging utilities, so kubectl exec is insufficient.

Commands

# Add a debug container that shares the target's process namespace
kubectl debug -it ephemeral-demo --image=busybox:1.28 --target=ephemeral-demo

# Debug a copy of the Pod instead, with shared processes
kubectl debug myapp -it --image=ubuntu --share-processes --copy-to=myapp-debug

# Shell on a node (root filesystem at /host)
kubectl debug node/mynode -it --image=ubuntu

How they differ from regular containers

Flags and caveats

Permissions

The pods/ephemeralcontainers subresource is not included in the default admin and edit ClusterRoles. Cluster administrators must grant the patch (and typically update) verb on it explicitly.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Debug Running Pods; kubernetes/website (GitHub), Ephemeral Containers (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, Debug Running Pods; kubernetes/website (GitHub), Ephemeral Containers (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors.

Cite this

Permanent ID: iil:note:pnrhybz1

iinventedlight. 2026. "kubectl debug adds an ephemeral container to a running Pod for troubleshooting." iinventedlight Library, iil:note:pnrhybz1, version of 2026-11-18. https://iinventedlight.com/library/notes/kubernetes-ephemeral-containers/. License: CC-BY-4.0.

@misc{iil_note_pnrhybz1,
  author = {{iinventedlight}},
  title = {{kubectl debug adds an ephemeral container to a running Pod for troubleshooting}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/kubernetes-ephemeral-containers/},
  note = {Permanent ID iil:note:pnrhybz1. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/kubernetes-ephemeral-containers.md.