问题原文
原帖链接 · Mikhail Vasin · CC BY-SA 3.0
This is a command that works:
$ echo 'hi there' | docker run -i ubuntu cat
hi there
This is a command that responds with an error message:
$ echo 'hi there' | docker run -it ubuntu cat
the input device is not a TTY
I would like to figure out exactly what happens here. Not just "remove -t and it'll be fixed".
I know that docker run's -t option stands for "Allocate a pseudo-TTY", and I have read historical overviews of what TTY stands for, but it didn't help me understand what kind of a contract is violated here.
已采纳解答
原帖链接 · Mikhail Vasin · CC BY-SA 3.0
This answer helped me to wrap my head around:
- by default (without neither
-inor-toptions) a Docker container only sends its output to STDOUT, - with
-ioption comes connection to STDIN, -toption pulls in a terminal interface driver, that works on top of STDIN/STDOUT. And when a terminal driver is pulled in, the communication with a container must conform to the terminal interface protocol. Piping a string does not.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
