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

Prepare for the Kubernetes Cloud Native Associate (KCNA) Certification test with engaging questions and detailed explanations. Perfect your knowledge and boost your confidence to pass the exam successfully!

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