Skip to content
masterclass Buddy

DevOps · Command

kubectl exec

Runs a command inside a container in a Kubernetes Pod. Use -- before the command, and use -c to select a container when needed.

Last updated

Syntax

kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • kubectl attach
  • kubectl logs
  • Get a Shell to a Running Container

Source: kubectl exec | Kubernetes. Checked 2026-11-03.