-t by far is the worst documented command for docker run for beginners.
Don’t get me wrong, I don’t say this to criticize the docker community but to bring to attention that more needs to be done in explaining this command. Most beginners, like myself included prefer memorizing it instead of learning what it does under the hood, which leads to some funny scenarios in productions.
Having said that I hope you will help me in getting a more in-depth understanding of what
-t does and how it interacts with its companion
-i Means keep the STDIN open even through it is not attached.
-t Allocates a pseudo terminal.
I have an idea as to what they do independently but I cannot understand what happens when they are clubbed together.
When I do:
docker run -it alpine cat
Here is my understanding of what happens:
1 ) Docker starts and attaches the
STDINto the input of
2 ) A
ttyis spun up and the
STDOUTis connected to the
STDINof the input stream made for
3 ) Thus whatever I type will go to
First of all am I right ?
I don’t think I am because if I do
docker run -i alpine cat
-t gives me near identical behaviour, so what is
-t actually doing ?
Also where is the pseudo terminal coming from? Is it from the system or the from docker ?
I tried reading the source but it didn’t answer my questions.
Thanks in advance.