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

TTY Error running interactive docker on Bash on Windows #1588

Open
waleedka opened this issue Jan 20, 2018 · 24 comments

Comments

@waleedka
Copy link

commented Jan 20, 2018

A quick search online showed that a lot of people are frustrated about this issue. Basically, I'm trying to run Docker for Windows from the Bash on WSL (Windows Subsystem for Linux) on Windows 10 Creator Edition.

 docker.exe run -it hello-world

Returns this error:

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

The suggested solutions typically require installing external tools to work around the issue. I prefer not to prefix all my docker commands with winpty because then my scripts won't run on Linux boxes. And, actually, I prefer not to have to install winpty or any other tool just to work-around this issue. Can someone at Docker fix the issue at the root please?

Based on this thread, it seems this is a Docker issue. Quoting:

This is a docker.exe issue, I believe. It is not aware of the new console functionality and probably duplicates it to some degree. We saw similar problems on Win32-OpenSSH. Basically, when compiling docker.exe, they need to flip a few console flags up on the IO handles and disable their built-in terminal emulation code to allow the Windows console to take over processing.

Please look into it. You'd save your community a lot of frustration.

@AnisAli

This comment has been minimized.

Copy link

commented Jan 31, 2018

Run without .exe
docker run -it hello-world

@jtrutwin

This comment has been minimized.

Copy link

commented Feb 23, 2018

Um, No different running without the .exe, not sure why you expected that would work

jtrutwin@DESKTOP-PAK1BAG MINGW64 ~/git-projects/Hive (master)
$ docker run -it hello-world
the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'

Also running into this issue, hoping there's a fix down the road. Thanks.

@waqas-mehmood-pk

This comment has been minimized.

Copy link

commented Apr 27, 2018

Anybody find the solution to this issue? I am facing this one too.

@samoldenburg

This comment has been minimized.

Copy link

commented May 30, 2018

Any update on this issue?

@ray1007

This comment has been minimized.

Copy link

commented Jul 19, 2018

I had the same problem. Below are my findings:

The command docker.exe run -it hello-world also failed in my WSL bash.
However I found the same command worked in both cmd and Powershell. (See below)
image
image
image

Perhaps one should not use docker.exe interactive/tty mode in WSL. I followed this guide to install docker client on WSL. And the command docker run -it hello-world executed with no error.
image

Still I haven't figured out why docker.exe works only on windows shells. I'd appreciate if someone could explain it! :)

Tzu-Ray

@docker-desktop-robot

This comment has been minimized.

Copy link
Collaborator

commented Oct 17, 2018

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@dekstroza

This comment has been minimized.

Copy link

commented Nov 1, 2018

Any news on this?

@tomasaschan

This comment has been minimized.

Copy link

commented Dec 17, 2018

/remove-lifecycle stale

I'm also wondering about this. Would be nice if this worked seamlessly in WSL!

@mrbarua

This comment has been minimized.

Copy link

commented Dec 21, 2018

On git bash just type:
alias docker="winpty docker"
and tty will work

after starting the docker I mean when it will run
do a docker login from PowerShell (git-bash )and then use git-bash

then create docker conatainer
docker container run -it -p 80:80 nginx

@LarsWH

This comment has been minimized.

Copy link

commented Jan 20, 2019

I was also seeing this problem, but after updating from version 1803 to 1809 it seems to have gone away (https://en.wikipedia.org/wiki/Windows_10_version_history).

@nngo

This comment has been minimized.

Copy link

commented Feb 22, 2019

If your application does not need to send output text/etc to another application (e.g. for piping), then you don't need to run using the --tty or -t option to create a pseudo-terminal (i.e. for STDOUT). Additionally, if the application does not need to read from STDIN (then you can also omit the --interactive or -i option) e.g.

# this should still output to your console
docker run hello-world

In response to #1588 (comment)
When running the nginx web server, most of the time you don't need the -it (aka STDIIN via --interactive and STDOUT via --tty for the psuedo-tty options)

docker run -p 80:80 nginx
@FDiskas

This comment has been minimized.

Copy link

commented Mar 2, 2019

I tried like so. Worked 😹
winpty docker run hello-world

@judgej

This comment has been minimized.

Copy link

commented Apr 2, 2019

April 2019 - still seems to be a problem on Windows 10. docker cannot be run interactively without running it through winpty.

@Ruegen

This comment has been minimized.

Copy link

commented May 11, 2019

same error here - I have to run it though winpty

@JoanComasFdz

This comment has been minimized.

Copy link

commented May 24, 2019

Just run into this error using zsh in Unbuntu in Hyper:

  • Windows 10 1709 Build 16299.1087
  • Docker Desktop Community 2.0.0.3 (31259) Build 8858db3 Engine 18.09.2.

When I run the command in cmd.exe it works.

@siochs

This comment has been minimized.

Copy link

commented Jul 10, 2019

Just ommitting -it because it's not required by the container is not a solution:

$ docker run --rm -it debian:latest /bin/bash
the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'

Using winpty wrapper is not acceptable from my point of view, because it messes up with parsing the command line and with the environment variables:

$ winpty docker run --rm -it debian:latest /bin/bash
C:/Program Files/Docker/Docker/Resources/bin/docker.exe: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"C:/Users/foo/AppData/Local/Programs/Git/usr/bin/bash.exe\": stat C:/Users/foo/AppData/Local/
Programs/Git/usr/bin/bash.exe: no such file or directory": unknown.
@LeeRuns

This comment has been minimized.

Copy link

commented Jul 10, 2019

Still does not work for me.

here is what i need to run from git bash on windows
~/$ winpty docker -it run simcompdocker /bin/bash stdin is not a tty

tried to drop the -i bc it is griping about input so i changed to this
~/$ winpty docker -t run simcompdocker /bin/bash stdin is not a tty

tried to drop all stdin stdout related work
~$ winpty docker run hello-world stdin is not a tty
setup is

  1. git-bash
  2. docker full windows install
@movielovers

This comment has been minimized.

Copy link

commented Jul 23, 2019

Just ommitting -it because it's not required by the container is not a solution:

$ docker run --rm -it debian:latest /bin/bash
the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'

Using winpty wrapper is not acceptable from my point of view, because it messes up with parsing the command line and with the environment variables:

$ winpty docker run --rm -it debian:latest /bin/bash
C:/Program Files/Docker/Docker/Resources/bin/docker.exe: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"C:/Users/foo/AppData/Local/Programs/Git/usr/bin/bash.exe\": stat C:/Users/foo/AppData/Local/
Programs/Git/usr/bin/bash.exe: no such file or directory": unknown.

I didn't put the full path in for bash and it worked for me
winpty docker run --rm -it debian:latest bash

@LeeRuns

This comment has been minimized.

Copy link

commented Jul 23, 2019

bump

@sbkg0002

This comment has been minimized.

Copy link

commented Jul 25, 2019

Bump

@siochs

This comment has been minimized.

Copy link

commented Jul 25, 2019

I didn't put the full path in for bash and it worked for me
winpty docker run --rm -it debian:latest bash

Okay, but this appears to me more like a workaround than a solution. Based on your hint, I found the following commands also working (which for the moment confuses me):
winpty docker run --rm -it debian:latest bin/bash
winpty docker run --rm -it debian:latest //bin//bash
winpty docker run --rm -it debian:latest //bin/bash
Also things like
winpty docker run --rm -it debian:latest //bin/bash -c "echo 'hello'"
work...

I don't know. Using winpty feels for me like installing a keyboard-driver-for-notepad.

@movielovers

This comment has been minimized.

Copy link

commented Jul 25, 2019

Still does not work for me.

here is what i need to run from git bash on windows
~/$ winpty docker -it run simcompdocker /bin/bash stdin is not a tty

tried to drop the -i bc it is griping about input so i changed to this
~/$ winpty docker -t run simcompdocker /bin/bash stdin is not a tty

tried to drop all stdin stdout related work
~$ winpty docker run hello-world stdin is not a tty
setup is

  1. git-bash
  2. docker full windows install

winpty docker -it run simcompdocker /bin/bash

this is incorrect so the -it goes after the run so
winpty docker run -it simcompdocker bash

Either way if even easy commands are failing like hello-world. Almost looks like something is not installed right.

$ winpty docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.

$ docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.

didnt even need winpty to run hello-world
I would say if its feasible maybe reinstall if you dont lose too much.

I also am using git-bash and windows docker full install, windows 10. But i am not expert here.

@dsebastien

This comment has been minimized.

Copy link

commented Aug 28, 2019

This is the alias I'm using, which seem to do the trick: docker(){(export MSYS_NO_PATHCONV=1; "winpty" "docker" "$@")}

@osoese

This comment has been minimized.

Copy link

commented Sep 7, 2019

#!/bin/bash
docker run --name myshellbox --privileged -d shellbox
TEST_IT=$(docker exec myshellbox echo "Hello from container!")
echo ${TEST_IT}

this two step approach to get the output is what I use as a workaround when scripting to container

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.