Command

Kubernetes Open a Shell in a Pod Command

The Kubernetes command to open a shell in a pod is kubectl exec --stdin --tty my-pod -- /bin/sh.

Quick Answer

Command
kubectl exec --stdin --tty my-pod -- /bin/sh
KubernetesCommand

Open a Shell in a Pod

Type this command
kubectl exec --stdin --tty my-pod -- /bin/sh

Opens an interactive shell into a running pod.

Learn More

How to open a shell in a pod in Kubernetes

  1. Open the terminal or command interface for Kubernetes.
  2. Type kubectl exec --stdin --tty my-pod -- /bin/sh, replace any placeholders, and run it.

Kubernetes Open a Shell in a Pod Command

Run kubectl exec --stdin --tty my-pod -- /bin/sh.

Related Commands

Frequently asked questions

What is the Kubernetes command to open a shell in a pod?

Run kubectl exec --stdin --tty my-pod -- /bin/sh.

Where do I type this Kubernetes command?

Type it in the terminal or command-line interface used by Kubernetes.

Does this Kubernetes command work on Mac and Windows?

Yes. The command text is the same on both platforms when the tool is installed.

Official source · How we verify