windows docker 错误:输入设备不是 TTY。如果您使用的是 mintty,请尝试在命令前加上 'winpty'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48623005/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:02:30  来源:igfitidea点击:

docker error : the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'

windowsgitdockergithubtty

提问by Vipul Rao

After i run this
$ docker run --rm -v "/c/users/vipul rao/documents/github/wappalyzer:/opt/wappalyzer" -it wappalyzer/dev

在我运行这个之后
$ docker run --rm -v "/c/users/vipul rao/documents/github/wappalyzer:/opt/wappalyzer" -it wappalyzer/dev

I am getting the following error the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'What should i use here i am running on windows 8 in MINGW64.

我收到以下错误the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'我应该在这里使用什么我在 MINGW64 的 Windows 8 上运行。

回答by ErikMD

As suggested by the error message you obtain, you should try to use winpty(which is installed by default with Git-Bash) and thus run:

正如您获得的错误消息所建议的那样,您应该尝试使用winpty(默认情况下随 Git-Bash 安装),然后运行:

winpty docker run --rm -v "/c/users/vipul rao/documents/github/wappalyzer:/opt/wappalyzer" -it wappalyzer/dev

If this works, you may want to set a Bash alias to avoid manually prepending winptyall the time:

如果可行,您可能需要设置 Bash 别名以避免一直手动添加winpty

echo "alias docker='winpty docker'" >> ~/.bashrc

or

或者

echo "alias docker='winpty docker'" >> ~/.bash_profile

回答by yamenk

This problem occurs when running with -itoption using bash terminal on windows. You can use Powershell to resolve this issue.

-it在 Windows 上使用 bash 终端使用选项运行时会出现此问题。您可以使用 Powershell 来解决此问题。

回答by w3outlook

If you are using Git Bash you can try like this

如果您正在使用 Git Bash,您可以尝试这样

winpty docker run -it ubuntu

回答by Red Cricket

Did you start "Docker Quickstart Terminal"? I was trying to run

你启动了“Docker Quickstart Terminal”吗?我试着跑

$ docker run -i -t redcricket/react-tutorial:latest /bin/bash

on windows from a Cygwin bash shell and got the same error:

在来自 Cygwin bash shell 的 Windows 上并得到相同的错误:

the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'

Then I remembered that when I installed docker on my windows 10 system something called "Docker Quickstart Terminal" got installed. You need to start that first from that dumb windows 'Type here to search' thing on the task bar:

然后我记得当我在 Windows 10 系统上安装 docker 时,安装了一个名为“Docker Quickstart Terminal”的东西。您需要先从任务栏上那个愚蠢的窗口“在此处键入以进行搜索”开始:

enter image description here

在此处输入图片说明

That launches this …

这启动了这个……

enter image description here

在此处输入图片说明

… you can run your docker commands there without getting that error or running winpty.

...您可以在那里运行您的 docker 命令而不会出现该错误或运行 winpty。

回答by Harsh

Remove -itfrom the command. If you want to keep it interactive then keep -i

-it从命令中删除。如果你想保持互动,那就保持-i

回答by Muhammad SaLman

Just add 'winpty' in start of your cmd ,Try below:

只需在你的 cmd 开头添加“winpty”,试试下面的:

$ winpty docker.exe run --rm -v "/c/users/vipul rao/documents/github/wappalyzer:/opt/wappalyzer" -it wappalyzer/dev

Why this happens? More details here: http://willi.am/blog/2016/08/08/docker-for-windows-interactive-sessions-in-mintty-git-bash/

为什么会发生这种情况?更多细节在这里:http: //willi.am/blog/2016/08/08/docker-for-windows-interactive-sessions-in-mintty-git-bash/

回答by Jason Spick

Got this error for running docker-compose exec workspace bash

运行时出现此错误 docker-compose exec workspace bash

So just prefix with winpty winpty docker-compose exec workspace bash

所以只需以 winpty 为前缀 winpty docker-compose exec workspace bash

回答by Naveen Yadav

The problem is with gitbash however with the powershell it is working fine ..

问题出在 gitbash 上,但是在 powershell 中它运行良好..

回答by cesarpino

Don't use alias docker="winpty docker". It solves your problem but break pipes.

不要使用 alias docker="winpty docker". 它可以解决您的问题,但会破坏管道。

$ winpty docker run -ti ubuntu
root@e85cff7d1670:/# exit

$ wintpy docker run ubuntu bash HELLO 
HELLO

$ wintpy docker run ubuntu bash HELLO | cat
stdout is not a tty

Copy this to your .bashrc. This script uses winpty dockeronly if -tiis used.

将其复制到您的 .bashrc。此脚本winpty docker仅在-ti使用时使用。

function docker(){
  for param; do if [[ "$param" == "-ti" ]] || [[ "$param" == "-it" ]]; then 
    winpty docker "$@"; return
  fi; done; 
  command docker "$@"
}

docker run -ti ubuntubecomes winpty docker run -ti ubuntuavoids error: the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'"

docker run -ti ubuntu变得winpty docker run -ti ubuntu回避error: the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'"

docker run ubuntu echo "what's up" | catbecomes command docker run echo "what'up" | catavoids error: stdout is not a tty

docker run ubuntu echo "what's up" | cat变得command docker run echo "what'up" | cat回避error: stdout is not a tty

The script only looks if there is a '-it' parameter without checking if it is inside a 'docker run' sentence... but it does the trick for my uses.

该脚本只查看是否有“-it”参数,而不会检查它是否在“docker run”语句中……但它对我的使用很有帮助。

回答by FunkMasterP

It may be that you're not running your commands within the Docker terminal. If you don't, you may not be properly connected to the Docker daemon and won't be able to interact correctly.

可能是您没有在 Docker 终端中运行您的命令。如果不这样做,您可能无法正确连接到 Docker 守护程序,并且无法正确交互。

Make sure you're running commands in the actual Docker Terminal.

确保您在实际的 Docker 终端中运行命令。