Bird
0
0

You want to run a command inside a container but the pod has two containers named frontend and backend. You want to run curl localhost inside the backend container. Which command is correct?

hard📝 Workflow Q9 of 15
Kubernetes - kubectl Essential Commands
You want to run a command inside a container but the pod has two containers named frontend and backend. You want to run curl localhost inside the backend container. Which command is correct?
Akubectl exec pod1 -- curl localhost -c backend
Bkubectl exec -it pod1 -- curl localhost -c backend
Ckubectl exec -it pod1 -c backend -- curl localhost
Dkubectl exec pod1 -c backend curl localhost
Step-by-Step Solution
Solution:
  1. Step 1: Specify container with -c before command

    The container flag -c backend must come before the command and after pod name.
  2. Step 2: Use -it for interactive if needed

    kubectl exec -it pod1 -c backend -- curl localhost correctly uses -it and places flags properly before the command.
  3. Final Answer:

    kubectl exec -it pod1 -c backend -- curl localhost -> Option C
  4. Quick Check:

    Container flag -c before command, pod name before flags [OK]
Quick Trick: Place -c container before command, after pod name [OK]
Common Mistakes:
  • Placing -c after command
  • Omitting -- before command

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes