CertGrid CertGrid
Troubleshooting·Certified Kubernetes Application Developer

Debugging a Container Without a Shell

Minimal and distroless images have no shell, so `kubectl exec` fails and the standard debugging routine stops at step one. `kubectl debug` adds an ephemeral container to the running Pod - sharing its network namespace, so it sees the same IP and can reach the same things - without restarting anything. The `--copy-to` variant covers the case where the Pod will not stay up long enough.

Observability and Maintenance Guide 42 of 44 Intermediate

Written against the versions above. An ephemeral container cannot be removed once added. It stays in the Pod's spec until the Pod is deleted, which is a reason to prefer `--copy-to` on anything running in production - it leaves the original untouched.

One Pod running `pause`, which contains no shell and no userland at all.
Server NameIP AddressOSRolesCPURAMHDD
CKA1001192.168.0.175Ubuntu 26.04 LTSControl Plane Node2 Core4 GB50 GB
CKA1001-NODE01192.168.0.176Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE02192.168.0.177Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE03192.168.0.178Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB

Before you start

  1. A container with no shell

  2. Attach a container that does have one

  3. What it did to the Pod

  4. A copy with a different command

Official sources