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

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

问题描述

这个选项究竟在做什么?我在TTY上读了很多,但仍然感到困惑。我没玩过 -t ,而只是 -i ,似乎是希望用户输入的程序会抛出没有 -t 的错误。为什么要启用伪TTY很重要?

解决方案

-t参数没有记录好,或者提到许多人经常根据Google搜索。



当您通过键入显示所有docker客户端参数的列表(甚至应该是)时,它甚至不显示docker在Bash提示符下(最新版本为1.8.1)。



事实上,如果您尝试通过键入docker获得有关此参数的具体帮助-t -help如果给出这个令人惊讶的模糊答复:



提供但未定义的标志:-t



所以,你不能因为这个论点而感到困惑了!



在Docker在线文档中提到说,它是分配伪tty,通常与-i一起使用:



https://docs.docker.com/reference/run/



我看到它在文件中用于极好的jwilder / nginx-proxy码头容器,方式如下:



docker run -d -p 80:80 --name nginx -v /tmp/nginx:/etc/nginx/conf.d -t nginx



在这种情况下,它的作用是将输出发送到此docker容器内的'virtual'tty(Bash命令提示符/终端)。然后,您可以通过运行docker命令docker logs CONTAINER来查看此输出,其中CONTAINER是此容器ID的前几个字符。这个CONTAINER ID可以通过键入docker ps -a找到。



我在以下链接中简要提到了这个-t -t和-i标志分配一个伪tty,并保持stdin打开,即使没有附加,这将允许您像传统的VM一样使用容器,只要bash提示符正在运行。



https:// coreos。 com / os / docs / latest / getting-started-with-docker.html



希望这有帮助!我不知道为什么这不是文档或使用太多。也许这是实验性的,并将在即将发布的版本中作为文档化功能实现。


What exactly does this option do? I've been reading a lot on TTY and am still confused. I played around with not 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?

解决方案

The "-t" argument is NOT documented well, or mentioned by many people often, according to a Google search.

It doesn't even show up when you display a list of (what should be) all docker client arguments by typing "docker" at the Bash prompt (with the latest version of 1.8.1).

In fact, if you try to get specific help about this argument by typing "docker -t --help" if gives this amazingly vague reply:

"flag provided but not defined: -t"

So, you can't be blamed for being confused about this argument!

There is a mention in the Docker online documention which says it is to "Allocate a pseudo-tty" and is often used with -i:

https://docs.docker.com/reference/run/

I saw it used in the documentation for the terrific jwilder/nginx-proxy docker container in the following way:

docker run -d -p 80:80 --name nginx -v /tmp/nginx:/etc/nginx/conf.d -t nginx

In this case, what it does is send the output to the 'virtual' tty (Bash command prompt/terminal) within this docker container. You can then see this output by running the docker command "docker logs CONTAINER" where CONTAINER is the first couple of characters of this container's ID. This CONTAINER ID can be found by typing "docker ps -a"

I've seen this "-t" argument mentioned briefly in the following link, where it says, "The -t and -i flags allocate a pseudo-tty and keep stdin open even if not attached. This will allow you to use the container like a traditional VM as long as the bash prompt is running."

https://coreos.com/os/docs/latest/getting-started-with-docker.html

I hope this helps! I'm not sure why this isn't documented or used much. Maybe it's experimental and will be implemented as a documented feature in upcoming versions.

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

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