You are debugging a connection issue and want to run a temporary diagnostic container using the 'busybox' image inside the namespace 'staging', interact with its shell, and have the container be automatically deleted as soon as you exit the shell. Which command should you run?

Direct Answer (Verified)Reviewed by Sunny (Senior Cloud Engineer)

Correct Answer: kubectl run dns-test --image=busybox -n staging -it --rm -- sh

'kubectl run' runs a pod. The '-it' flags make it interactive, '--rm' ensures the pod is deleted automatically when it terminates, and '-- sh' runs the shell command inside the con...

Real Exam ScenarioKubernetes CLI

You are debugging a connection issue and want to run a temporary diagnostic container using the 'busybox' image inside the namespace 'staging', interact with its shell, and have the container be automatically deleted as soon as you exit the shell. Which command should you run?

✓ Correct Answer & ExplanationKubernetes CLI

Correct Answer

kubectl run dns-test --image=busybox -n staging -it --rm -- sh

Why This Answer Is Correct

'kubectl run' runs a pod. The '-it' flags make it interactive, '--rm' ensures the pod is deleted automatically when it terminates, and '-- sh' runs the shell command inside the container.

📚 What This Question Tests

This question evaluates your knowledge of Kubernetes CLI — a core concept tested in cloud certification exams. Understanding Kubernetes CLI is essential for designing scalable, secure, and cost-effective cloud architectures. Mastery of this topic will help you answer scenario-based questions confidently on exam day.