What does the -it option do when running a Docker container?

Study for the Kubernetes Cloud Native Associate (KCNA) Certification 1 Test. Master the core concepts of Kubernetes with multiple-choice questions and detailed explanations. Prepare and boost your confidence for the KCNA certification exam!

Multiple Choice

What does the -it option do when running a Docker container?

Explanation:
Running a container with -it creates an interactive session with a terminal inside the container. The -i flag keeps STDIN open, allowing you to type input, while the -t flag allocates a pseudo-TTY so you get a terminal-like interface. Together, they enable you to start the container and interact with its shell as if you were using a local machine, which is handy for debugging or exploring what’s inside. If you want a container to run in the background without sharing your terminal, you’d use detached mode with -d. The other options mentioned serve different tasks, like viewing image history or setting a restart policy, not interactive usage.

Running a container with -it creates an interactive session with a terminal inside the container. The -i flag keeps STDIN open, allowing you to type input, while the -t flag allocates a pseudo-TTY so you get a terminal-like interface. Together, they enable you to start the container and interact with its shell as if you were using a local machine, which is handy for debugging or exploring what’s inside. If you want a container to run in the background without sharing your terminal, you’d use detached mode with -d. The other options mentioned serve different tasks, like viewing image history or setting a restart policy, not interactive usage.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy