What is the purpose of the "t" flag when running the 'docker run' command?

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 is the purpose of the "t" flag when running the 'docker run' command?

Explanation:
Allocating a pseudo‑TTY for interactive use. The t flag tells Docker to allocate a terminal interface for the container, connecting its input and output to your host terminal. This enables interactive programs inside the container to run as if you were at a real terminal, showing prompts, colors, and letting you type commands. It’s most useful when you want an interactive shell inside the container, often used together with the interactive flag, as in docker run -it … /bin/bash. Without a TTY, the shell runs in non‑interactive mode, which can make prompts and formatting behave oddly or prevent real-time input. The other options serve different purposes: one maps ports to the host, another runs the container in the background, and setting the time zone is typically done via an environment variable rather than a terminal flag.

Allocating a pseudo‑TTY for interactive use. The t flag tells Docker to allocate a terminal interface for the container, connecting its input and output to your host terminal. This enables interactive programs inside the container to run as if you were at a real terminal, showing prompts, colors, and letting you type commands. It’s most useful when you want an interactive shell inside the container, often used together with the interactive flag, as in docker run -it … /bin/bash. Without a TTY, the shell runs in non‑interactive mode, which can make prompts and formatting behave oddly or prevent real-time input. The other options serve different purposes: one maps ports to the host, another runs the container in the background, and setting the time zone is typically done via an environment variable rather than a terminal flag.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy