Docker exec -it returns "cannot enable tty mode on input without tty"

docker exec -it command returns the following error: "it is impossible to enable tty-mode at the input without tty"

 level="fatal" msg="cannot enable tty mode on non tty input" 

I run docker (1.4.1) in the centos 6.6 field. I am trying to execute the following docker exec -it containerName /bin/bash but I am getting the following error

 level="fatal" msg="cannot enable tty mode on non tty input" 
+55
docker centos
Mar 31 '15 at 23:34
source share
8 answers

Running docker exec -i instead of docker exec -it fixed my problem. Indeed, my script was run by CRONTAB, which is not a terminal.

We remind you:

 Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...] Run a command in a running container -i, --interactive=false Keep STDIN open even if not attached -t, --tty=false Allocate a pseudo-TTY 
+77
Nov 04 '15 at 17:16
source share

If you get this error in the docker client for Windows , you may need to use the launch command below

$ winpty docker run -it ubuntu /bin/bash

+14
Dec 26 '15 at 23:18
source share

just use "-i"

docker exec -i [your-ps] [command]

+8
Aug 17 '16 at 14:34
source share

If you use Windows and use a docker machine, and you use GIT Bash or Cygwin to "get inside" a working container, you need to do the following:

docker-machine ssh default in ssh to a virtual machine (most likely Virtualbox)

docker exec -it <container> bash to get into the container.

EDIT:

I recently discovered that if you use Windows PowerShell, you can run dockers directly in the container using Cygwin or GIT Bash, you can use winpty docker exec -it <container> bash and skip the docker-machine ssh step above.

+7
Mar 21 '16 at 16:55
source share

I get "can't enable tty mode on non tty input" for the next command in windows with boot2docker

 docker exec -it <containerIdOrName> bash 

Below command is fixed problem

 winpty docker exec -it <containerIdOrName> bash 
+5
Dec 31 '15 at 19:30
source share

docker exec runs a new command in an already running container . This is not a way to start a new container - use docker run to do this.

This may be the cause of the "non tty input" input error. Or it could be where you use docker. Is this a real terminal? That is, is there a full tty session? You can check if you are in an interactive session with

 [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive' 

from https://unix.stackexchange.com/questions/26676/how-to-check-if-a-shell-is-login-interactive-batch

+4
Apr 01 '15 at 23:01
source share

I came across the same error message on Windows 7 64bit using the Mintty that ships with Git for Windows. $docker run -i -t ubuntu /bin/bash cannot enable tty mode on non tty input

I tried prefixing the above winpty command, like the other suggested answers, but running it showed me another error message below: $ winpty docker run -i -t ubuntu /bin/bash exec: "D:\\Git\\usr\\bin\\bash": executable file not found in $PATH docker: Error response from daemon: Container command not found or does not exist..

Then I had to run the following command, which gave me what I want: $ winpty docker run -i -t ubuntu bash root@512997713d49:/# ls bin dev home lib64 mnt proc run srv tmp var boot etc lib media opt root sbin sys usr root@512997713d49:/#

+3
Apr 12
source share

I run docker exec -it in jenkins jobs and get error 'cannot enable tty mode for input without tty. There is no return to the docker exec command. My account was as follows:

 jenkins shell -> ssh user@<testdriver> -> ssh root@<sut> -> su - <user> -> docker exec -it <container> 

I made changes to using the -T flag in the original ssh from jenkins. "-T - Disable pseudo-terminal distribution." And use the -i flag with docker exec instead of -it. "-i - interactive. -t - highlight pseudo-tty.". This seems to have solved my problem.

 jenkins shell -> ssh -T user@<testdriver> -> ssh root@<sut> -> su - <user> -> docker exec -i <container> 

The behavior type corresponds to this docker exec tty error: https://github.com/docker/docker/issues/8755 . The workaround in this discussion of docker errors involves using this:

 docker exec -it <CONTAINER> script -qc <COMMAND> 

Using this workaround did not solve my problem. It is interesting. Try using them with different flags and with different ssh calls you can see "not tty" even when using -t with docker exec:

 $ docker exec -it <CONTAINER> script -qc 'tty' /dev/pts/0 $ docker exec -it <CONTAINER> 'tty' not a tty $ docker exec -it <CONTAINER> bash -c 'tty' not a tty 
0
Jul 27 '16 at 15:46
source share



All Articles