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

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

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