Which command provides an interactive shell inside a running container, testing ability to reach /bin/bash?

Study for the Kubernetes Cloud Native Associate (KCNA) Certification. Prepare with flashcards and multiple choice questions. Ensure success with detailed explanations. Ready for your exam!

Multiple Choice

Which command provides an interactive shell inside a running container, testing ability to reach /bin/bash?

Explanation:
To get an interactive shell inside a running container, you use kubectl exec with a TTY. The -i option keeps standard input open and the -t option allocates a pseudo-terminal, which together let you interact with the shell. If the Pod has multiple containers, you specify which container with -c. After a double dash, you provide the command to run inside the container; to test reachability of /bin/bash, you launch the shell itself (commonly /bin/bash). This approach is the right one because it directly runs a new shell inside the existing container context, giving you an interactive session to verify that /bin/bash is available and functioning. Other options either attach to an existing process rather than starting a new shell, create a new pod instead of using the current one, or misuse command syntax that doesn’t spawn a shell inside the container.

To get an interactive shell inside a running container, you use kubectl exec with a TTY. The -i option keeps standard input open and the -t option allocates a pseudo-terminal, which together let you interact with the shell. If the Pod has multiple containers, you specify which container with -c. After a double dash, you provide the command to run inside the container; to test reachability of /bin/bash, you launch the shell itself (commonly /bin/bash).

This approach is the right one because it directly runs a new shell inside the existing container context, giving you an interactive session to verify that /bin/bash is available and functioning. Other options either attach to an existing process rather than starting a new shell, create a new pod instead of using the current one, or misuse command syntax that doesn’t spawn a shell inside the container.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy