错误“输入设备不是TTY". [英] Error "The input device is not a TTY"

查看:144
本文介绍了错误“输入设备不是TTY".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Jenkinsfile运行以下命令.但是,出现错误输入设备不是TTY" .

I am running the following command from my Jenkinsfile. However, I get the error "The input device is not a TTY".

docker run -v $PWD:/foobar -it cloudfoundry/cflinuxfs2 /foobar/script.sh

是否可以在不进行交互模式的情况下从Jenkinsfile运行脚本?

Is there a way to run the script from the Jenkinsfile without doing interactive mode?

我基本上有一个名为script.sh的文件,我想在Docker容器中运行.

I basically have a file called script.sh that I would like to run inside the Docker container.

推荐答案

从cli中删除-it,使其变为非交互式,并删除TTY.如果您不需要任何一个,例如在Jenkins或cron脚本中运行命令,则应执行此操作.

Remove the -it from your cli to make it non interactive and remove the TTY. If you don't need either, e.g. running your command inside of a Jenkins or cron script, you should do this.

或者如果您输入的输入不是来自TTY的docker命令,也可以将其更改为-i.如果您的命令行中有xyz | docker ...docker ... <input之类的内容,请执行此操作.

Or you can change it to -i if you have input piped into the docker command that doesn't come from a TTY. If you have something like xyz | docker ... or docker ... <input in your command line, do this.

或者如果您想要TTY支持但在输入设备上不可用,则可以将其更改为-t.这样做是为了对日志中的输出进行颜色格式化,或者以后再使用适当的终端将其连接到容器时.

Or you can change it to -t if you want TTY support but don't have it available on the input device. Do this for color formatting of the output in your logs, or for when you later attach to the container with a proper terminal.

或者,如果您需要交互式终端并且不在Linux或MacOS的终端中运行,请使用其他命令行界面.据报道,PowerShell在Windows上提供了这种支持.

Or if you need an interactive terminal and aren't running in a terminal on Linux or MacOS, use a different command line interface. PowerShell is reported to include this support on Windows.

什么是TTY?这是一个终端接口,它支持颜色输出,转义序列,移动光标等,这是从老式笨拙的终端连接到大型机而来的.今天,它是由Linux命令终端和ssh接口提供的.有关更多详细信息,请参见维基百科文章.

What is a TTY? It's a terminal interface that supports color output, escape sequences, moving the cursor around, etc, that comes from the old days of dumb terminals attached to mainframes. Today it is provided by the Linux command terminals and ssh interfaces. See the wikipedia article for more details.

这篇关于错误“输入设备不是TTY".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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