Bird
0
0

What will be the output of this command if the pod db-pod has a container named mysql running and you execute:

medium📝 Command Output Q13 of 15
Kubernetes - kubectl Essential Commands
What will be the output of this command if the pod db-pod has a container named mysql running and you execute:
kubectl exec db-pod -c mysql -- ls /var/lib/mysql?
ALists files and directories inside /var/lib/mysql in the mysql container
BShows an error: container mysql not found
CLists files in the host machine's /var/lib/mysql directory
DStarts an interactive shell inside the mysql container
Step-by-Step Solution
Solution:
  1. Step 1: Understand the command

    The command runs ls /var/lib/mysql inside the mysql container of the db-pod pod. It lists files in that directory inside the container.
  2. Step 2: Eliminate wrong options

    Shows an error: container mysql not found is wrong because the container exists. Lists files in the host machine's /var/lib/mysql directory is wrong because kubectl exec runs inside container, not host. Starts an interactive shell inside the mysql container is wrong because no shell is started; only ls runs.
  3. Final Answer:

    Lists files and directories inside /var/lib/mysql in the mysql container -> Option A
  4. Quick Check:

    kubectl exec runs command inside container = Lists files and directories inside /var/lib/mysql in the mysql container [OK]
Quick Trick: kubectl exec runs command inside container, not host [OK]
Common Mistakes:
  • Thinking command runs on host machine
  • Confusing exec with shell start
  • Assuming container does not exist

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes