对分配伪 TTY 的 Docker -t 选项感到困惑 [英] Confused about Docker -t option to Allocate a pseudo-TTY

查看:47
本文介绍了对分配伪 TTY 的 Docker -t 选项感到困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个选项到底有什么作用?我已经在 TTY 上阅读了很多,但我仍然感到困惑.我在没有 -t 和只有 -i 的情况下玩了起来,似乎希望用户输入的程序在没有 -t 的情况下抛出错误.为什么启用伪 TTY 很重要?

What exactly does this option do? I've been reading a lot on TTY and I'm still confused. I played around without having the -t and just -i and it seems like programs that expect user input throw an error without the -t. Why is it important for pseudo-TTY to be enabled?

推荐答案

-t 选项适用于 Unix/Linux 如何处理终端访问.过去,终端是硬线连接,后来是基于调制解调器的连接.这些有物理设备驱动程序(它们是真正的设备).一旦通用网络投入使用,就开发了伪终端驱动程序.这是因为它在理解哪些终端功能可以使用而无需直接将其写入您的程序(阅读sttycurses 上的手册页)之间产生了分离.

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).

所以,以它为背景,运行一个没有选项的容器,默认情况下你有一个标准输出流(所以 docker run | 工作);使用 -i 运行,并添加 stdin 流(所以 | docker run -i 有效);使用 -t,通常在组合 -it 中,并且您添加了一个终端驱动程序,如果您正在与进程交互,这可能是您想要的.它基本上使容器启动看起来像一个终端连接会话.

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.

这篇关于对分配伪 TTY 的 Docker -t 选项感到困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆