DevotionGeo

DevotionGeo

Can someone explain the -t option/flag in docker run command?

I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run command says about this flag, which is the following,

       -t, --tty=true|false
          Allocate a pseudo-TTY. The default is false.

       When set to true Docker can allocate a pseudo-tty and attach to the standard input of
       any container. This can be used, for example, to run a throwaway interactive shell.
       The default is false.

       The -t option is incompatible with a redirection of the docker client standard input.

Things like pseudo-TTY or “attaching to the standard input”. So if this interactive shell isn’t the standard input for docker container, what is actually the standard input, to which it attaches?

7 7342 2

Most Liked

AstonJ

AstonJ

Was curious about this too so did some googling :blush:

A pseudo TTY is:

A pseudo TTY (or “PTY”) is a pair of devices — a slave and a master — that provide a special sort of communication channel. The slave device behaves much like the device representing the VT100 or ADM-3A “dumb terminal” that we all have on our desks … or that we might have had a few decades ago.

From: Containers, pseudo TTYs, and backward compatibility [LWN.net]

And how it relates to Docker:

The -t option goes to how Unix/Linux handles terminal access. In the past, a terminal was a hardline connection, later a modem based connection. These had physical device drivers (they were real pieces of equipment). Once generalized networks came into use, a pseudo-terminal driver was developed. This is because it creates a separation between understanding what terminal capabilities can be used without the need to write it into your program directly (read man pages on stty , curses ).

So, with that as background, run a container with no options and by default you have a stdout stream (so docker run | <cmd> works); run with -i , and you get stdin stream added (so <cmd> | docker run -i works); use -t , usually in the combination -it and you have a terminal driver added, which if you are interacting with the process is likely what you want. It basically makes the container start look like a terminal connection session.

Source: Confused about Docker -t option to Allocate a pseudo-TTY - Stack Overflow

DevotionGeo

DevotionGeo

Thank you for the detailed reply! :slight_smile:
Now I know how it works under the hood.

Where Next?

Popular Backend topics Top

DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
7 7340 2
New
andrea
Can Phoenix LiveView be used in multi-page applications, unlike React/Vue/Blazor which seems to be targeted for SPA?
6 2432 4
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
7 3059 3
New
sampu
I have a use case where a client is invoking a Rest endpoint via a load balancer, which in turn invokes a third party endpoint which is r...
5 1720 1
New
Fl4m3Ph03n1x
Background I am trying to up my Functional Programming (FP) skills and one of the things that newcomers first learn in FP is the Option T...
12 1300 4
New
JimmyCarterSon
Hello, I am. very new to Elixir lang I have only been doing it for about 2 weeks. I recently started following this tutorial todo list, ...
12 2025 3
New
JimmyCarterSon
I am confused about the Schema setup, I am setting up a new application and I want to seed files in it as well. I tried to mix to create...
18 1160 7
New
conradwt
Hi, I’m building an application that will have support for both the web and mobile. At this time, I’m using PhxGenAuth for authenticatio...
6 1089 1
New
osbre
Hello everyone I’m trying to implement a “magic link” or “one-time login link” functionality I wonder what a secure way to implement it...
9 874 2
New
sona11
I studied very basic PHP (I believe). After that, I feel like I’ve gotten a handle on the language. My dream is to work as a web develope...
9 921 2
New

Other popular topics Top

ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
245 5335 101
New
Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
227 8684 88
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
243 5922 95
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
116 8174 31
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
3 3675 3
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
21 11128 7
New
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
1 3243 0
New
PragmaticBookshelf
Develop, deploy, and debug BEAM applications using BEAMOps: a new paradigm that focuses on scalability, fault tolerance, and owning each ...
40 2292 21
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
6 2202 3
New