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

雨燕双飞 提交于 2019-11-30 12:57:55

问题


After i run this
$ 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.


回答1:


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 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 winpty all the time:

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

or

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



回答2:


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




回答3:


If you are using Git Bash you can try like this

winpty docker run -it ubuntu



回答4:


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

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

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

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:

That launches this …

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




回答5:


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




回答6:


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.

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




回答7:


you can try with Cmder tool it will work. Its not working with Gitbash




回答8:


In addition to above mentioned solutions. In case you are getting this error for docker attach

example: docker attach alpine1

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

Solution: Adding winpty before docker command i.e. winpty docker attach should work.

example: winpty docker attach alpine1

Note: I was getting this error while using base on windows and this solution worked for me.




回答9:


For those using WSL and running Docker for windows inside of cmder or conemu I would recommend to not to use Docker which is installed on windows in 'Program Files' but instead install Docker inside WSL on ubuntu/linux. Do remember though that you can't run Docker itself from within WSL, you must connect to Docker running on windows from the linux Docker client installed in WSL.

To install Docker on WSL

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce

Your options for running actual Docker commands are to either: Connect to Docker using the switch -H

docker -H localhost:2375 run -it -v /mnt/c/code:/var/app -w "/var/app" centos:7

Or set the environment variable docker_host

export DOCKER_HOST=tcp://localhost:2375

Either way you are now be able to interactively connect to a running Docker container




回答10:


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

$ 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/



来源:https://stackoverflow.com/questions/48623005/docker-error-the-input-device-is-not-a-tty-if-you-are-using-mintty-try-prefi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!