Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"cannot enable tty mode on non tty input" in Cygwin in Windows #12469

Closed
elrac opened this issue Apr 17, 2015 · 77 comments
Closed

"cannot enable tty mode on non tty input" in Cygwin in Windows #12469

elrac opened this issue Apr 17, 2015 · 77 comments
Labels
kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. platform/windows

Comments

@elrac
Copy link

elrac commented Apr 17, 2015

When attempting to run docker in Cygwin(Babun) in Windows if the command uses the -t flag I receive the message:

>>docker run -ti ubuntu bash
time="2015-04-16T22:49:12-07:00" level=fatal msg="cannot enable tty mode on non tty input"

it seems like it isn't correctly passing the -t option to the underlying ssh call, but I don't know why that would be seeing as the ssh installed with git seems to have the same arguments as the one installed with Babun.

@ahmetb
Copy link
Contributor

ahmetb commented Apr 17, 2015

@elrac looks like a bug. I'll take a look soon. Can you please try on cmd.exe/powershell or msysgit (git bash for windows) to unblock yourself?

@ahmetb
Copy link
Contributor

ahmetb commented Apr 17, 2015

I'm actually aware of this. This showed up in my testing before. If we ask Win32 API if the stdout/stderr handles Cygwin passes are terminals or not, it says they're not. mSysgit or ConEmu doesn't do this nor does conhost based consoles (cmd.exe/powershell).

@elrac
Copy link
Author

elrac commented Apr 17, 2015

Figures that it would be a Cygwin issue. I'll probably go back to SSHing into the VM with Putty. Thank you for looking into it.

@ahmetb
Copy link
Contributor

ahmetb commented Apr 17, 2015

@elrac hmm interesting. Why do you really want to ssh into the VM? You can use mingw/conemu/powershell/cmd.exe.

@elrac
Copy link
Author

elrac commented Apr 17, 2015

@ahmetalpbalkan The problem with switching to another shell is that I already have my development environment set up the way I like it. I did try running Cygwin through conemu and I found that the terminal detection issue seems to be due to MinTTY, the terminal program that Cygwin uses. When I run the cygwin shell directly through conemu docker is able enable TTY mode.

@thaJeztah thaJeztah added platform/windows kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. labels Apr 17, 2015
@ahmetb
Copy link
Contributor

ahmetb commented Apr 17, 2015

@elrac I see. Let's keep the issue open, we'll probably need to add a hack to fix this behavior of Cygwin.

@suminb
Copy link

suminb commented Apr 21, 2015

I'm having this issue as well... (Windows 7, Cygwin)

@Andarius
Copy link

Same on Win 8.1 and cygwin

@mcmil
Copy link

mcmil commented May 20, 2015

👍 Same on Babun + Win 7

@alt-grr
Copy link

alt-grr commented May 20, 2015

👍

@noooonee
Copy link

+1 same on win 7 / cygwin

@stas410
Copy link

stas410 commented Jun 25, 2015

+1 same problem on windows 8.1 / cygwin

@jdmswong
Copy link

jdmswong commented Jul 1, 2015

+1 same issue please fix!

@johnecon
Copy link

johnecon commented Jul 5, 2015

+ 1 same here

@gidikern
Copy link

gidikern commented Jul 6, 2015

+1 same same

@elrac
Copy link
Author

elrac commented Jul 17, 2015

I'm still seeing this issue in version 1.7.1

@ryanmaclean
Copy link

+1 here as well... thanks guys!

@PhilCorney
Copy link

Also have this issue

@bobfields
Copy link

This is an issue when running 'docker -it' command (interactive terminal) when attempting to debug a Dockerfile. Yes we can use the host OS instead of the cygwin/Babun tty terminal, but most/all of the docs written for docker assume a Linux prompt/terminal. Is there a $TERM setting which will work correctly?

@thaJeztah
Copy link
Member

ping @ahmetalpbalkan do you know if there's any progress here in finding a hack/workaround?

@ahmetb
Copy link
Contributor

ahmetb commented Aug 10, 2015

@thaJeztah Not really, last time I checked, Cygwin was passing stdout/stderr descriptors that look just like actual files (it creates an effect like docker run -i -t busybox sh > out.txt) that's why this error is happening. I haven't had a chance to dig into this. @jstarks any ideas?

@elrac
Copy link
Author

elrac commented Aug 10, 2015

The problem isn't with Cygwin directly, but with the terminal app Mintty. Here is more information about the problem https://code.google.com/p/mintty/issues/detail?id=56 . A workaround would be to run Cygwin in a different command line app.

@ahmetb
Copy link
Contributor

ahmetb commented Aug 10, 2015

@elrac do you know if msys also uses mintty? (it says here) This problem doesn't happen on msys bash.

@nonsequitur
Copy link

This isn't directly related to Cygwin.
For example, the issue also appears when docker is called from a cmd.exe shell within Emacs. (Emacs 24.5.1 (i686-pc-mingw32))
But it works just fine in a Cygwin bash shell running inside a windowed top-level cmd.exe process.

@tdeheurles
Copy link

I reproduce the problem with ConEmu with bash/zsh.
I think mintty is here too.

@achekulaev
Copy link

+1
Having the same problem with bash/zsh on Babun

@SebNickel
Copy link

+1 on babun

@tdeheurles
Copy link

@edpichler Why not use ssh or the solution I propose ?

@edpichler
Copy link

@tdeheurles I just installed all the toolbox, started Docker Quickstarter Terminal and did "docker-machine ssh default".

After this, I can run the images bash. Thank you.

@debovema
Copy link

+1

"winpty" is my altenative but I'm waiting for a solution too.

@sathyaprasad
Copy link

+1 Windows 7

@dkop
Copy link

dkop commented Sep 22, 2015

+1 Windows 7 on Babun
But docker-compose works ok. In some cases you can use it instead docker.

@tiangolo
Copy link

I wrote a simple workaround / quick fix to allow using Docker Toolbox from Babun, it may help some of you:

https://github.com/tiangolo/babun-docker

With that you can keep using your docker commands as normal.

And if you are using Cygwin, you should use Babun, a very improved version of Cygwin.


You just have to run one command to setup everything. Although I encourage you to check the source code before running any script (including mine) in your terminal.

Inside, it installs and sets up winpty, and tries to start your default docker-machine VM and set up its environment.

Maybe it gets more relevant now since newer versions of Docker Toolbox come with Git 2.5, which uses mintty and has the same problem of "cannot enable tty mode on non tty input" as in Babun.

@tdeheurles
Copy link

hi @tiangolo, thank you, it works fine.
babun is great and I didn't how to with it.

@tiangolo
Copy link

I'm glad it helped @tdeheurles.
BTW, I wrote a guide on how to share folders to be used with Docker Volumes that work with Babun, to allow using commands like:

docker run -it -v $(pwd):/var/www ubuntu bash

The guide is here: https://github.com/tiangolo/babun-docker/wiki/Docker-Volumes-with-Babun

@stayclassychicago
Copy link

I'm not running Windows, but I'm seeing this issue running docker via maven-ant-plugin. I'm posting this here since #16089 was closed

Mac OSX 10.10.5

docker-machine version 0.4.1 (HEAD)
docker version
Client:
Version: 1.8.3
API version: 1.20
Go version: go1.5.1
Git commit: f4bf5c7
Built: Thu Oct 15 09:12:56 UTC 2015
OS/Arch: darwin/amd64

Server:
Version: 1.8.3
API version: 1.20
Go version: go1.4.2
Git commit: f4bf5c7
Built: Mon Oct 12 18:01:15 UTC 2015
OS/Arch: linux/amd64

Steps to reproduce

  1. Start docker-machine, eval, etc...
  2. Run maven to execute maven-antrun-plugin
    -antrun has step to exec: docker run -ti ${docker.mac.env} ${docker.image} ${docker.command}

Expected result
Docker run is executed with --tty and --interactive

Observed result
Command fails to execute with error message:

[exec] cannot enable tty mode on non tty input

Additional info
Running with either --tty or --interactive is successful, however the combination fails -- thus I'm not able to interactively pass the SIGINT signal to terminate the docker run command.

@ghost
Copy link

ghost commented Nov 4, 2015

I'm use this command to interactive with my container:

winpty docker exec -it mysqldb bash

mysqldb = container names
It's works for me

@seregasheypak
Copy link

@stayclassychicago, have same on MacOS using gradle exec:

task startDocker(type:Exec){
        commandLine "./test-in-docker.sh", uid //fails here: cannot enable tty mode on non tty input
}

If I run test-in-docker.sh docker_uid in console, it works fine.

@endosynth
Copy link

same problem under cygwin under windows 10 64-bit

+1

@tdeheurles
Copy link

The docker quickstart terminal seems to work without any issue for a long
time now. Maybe look if cygwin is mandatory ... As you have some linux tool
with the git bash ... Maybe it will do the work.

Le lun. 28 mars 2016 19:54, Andrew Proper notifications@github.com a
écrit :

same problem under cygwin under windows 10 64-bit

+1


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#12469 (comment)

@endosynth
Copy link

thanks @tdeheurles I have a path problem running docker.exe from the docker quickstart terminal but I'll work on fixing that to see if it will work once I have that fixed

@tiangolo
Copy link

@endosynth If you are using Cygwin you may well try babun-docker.

Babun is an improved Cygwin.

And babun-docker might be what you need: https://github.com/tiangolo/babun-docker

It's just a little program that works on top of Docker in the Babun Terminal (via Winpty), but makes the usage of Docker in Windows a lot simpler and closer to what was intended. Without having to SSH, adding and mounting shared volumes in your Virtual Machine, using Winpty directly and other things.

@endosynth
Copy link

I fixed my problem with the quickstart terminal by doing the following, so now it works OK for me:

  1. uninstalled docker tools
  2. re-installed docker tools
  3. docker quickstart wouldn't run so I rebooted PC (Win 10 x64)
  4. ran docker quickstart and now it works OK

Note that I also tried installing babun but it wasn't running properly for me so I removed it. I could have tried harder but wanted to try the quickstart terminal again first.

thanks!

@HugoPresents
Copy link

HugoPresents commented May 20, 2016

@tiangolo thank you very much!

btw, it's work with docker beta!

@lowenna
Copy link
Member

lowenna commented May 24, 2016

See #15272 and #22956. Closing.

@lowenna lowenna closed this as completed May 24, 2016
@lowenna
Copy link
Member

lowenna commented May 25, 2016

For completeness, you can use winpty to present a TTY-style input to mintty - it's even in the git for Windows installer. Couple of screenshots below - one for the installer, other showing an interactive docker attach and docker login from mintty, both not using (error case) and using (success case) winpty.
minttywinpty
winpty

@vickoman
Copy link

This works for me:

winpty docker run -it name-container-running bash

@rahmanya
Copy link

rahmanya commented Sep 8, 2017

I was having the same issue when I tried to run "docker run -it ubuntu bash" from cygwin.
here is what I did to resolve the issue:
Aparently, this problem is to do with MinTTY being implemented as pipes
instead of something that directly encapsulates a Windows console.

so the work around for this (after digging around some resources which I will reference below)
was to install WinPTY. This is a tool that launches a program in a typical Windows console,
captures the data, and forwards it to MinTTY seamlessly.

so I followed the guide from this website:
https://github.com/rprichard/winpty
after understanding that i needed to have the following cygwin packages:
-mingw64-x86_64-gcc-g++
-gcc-g++
-make

I decided to re-install the version of my installed cygwin (this is not actually necessary, but I just wanted to start
on a clean slate)
I decided to have the follwong packages installed with my fress install of cygwin:
lynx, wget, curl, rsync
-python, python3
-bzip, tar
-Bash-completion
-vim, vim-common
-tmux
-git
-diffutils
-make
-gcc-c, gcc-g++
-openssh
-ncurses

after installing cygwin, I ran:
cd /bin
then clone the repo from like thus:

git clone https://github.com/rprichard/winpty.git
then cd into the winpty directory and ran:
./configure, make and make install to setup the winpty package.

after that i tested my installtion from the cygein terminal: by entering the command:
$ winpty powershell
the result was success ! I got windows powershell propmt on cygwin

then i ran the docker exec command
$ winpty docker run -it ubuntu bash
and it worked !

but now i have some issues with my cygwin installation !
I keep getting " permission denied" error when I tried to
run ' apt-cyg' install command.

i get a permission denied message also when I tried to start a 'Dockerized webserver'
using the command:
docker run -d -p 80:80 --name webserver nginx from cygwi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. platform/windows
Projects
None yet
Development

No branches or pull requests