docker exec -it returns "cannot enable tty mode on non tty input"

docker exec -it command returns following error "cannot enable tty mode on non tty input"

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

I am running docker(1.4.1) on centos box 6.6. I am trying to execute the following command docker exec -it containerName /bin/bash but I am getting following error

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


Running docker exec -i instead of docker exec -it fixed my issue. Indeed, my script was launched by CRONTAB which isn't a terminal.

As a reminder:

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

If you're getting this error in windows docker client then you may need to use the run command as below

$ winpty docker run -it ubuntu /bin/bash

just use "-i"

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

If you're on Windows and using docker-machine and you're using GIT Bash or Cygwin, to "get inside" a running container you'll need to do the following:

docker-machine ssh default to ssh into the virtual machine (Virtualbox most likely)

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


I've recently discovered that if you use Windows PowerShell you can docker exec directly into the container, with Cygwin or Git Bash you can use winpty docker exec -it <container> bash and skip the docker-machine ssh step above.

I get "cannot enable tty mode on non tty input" for the following command on windows with boot2docker

docker exec -it <containerIdOrName> bash

Below command fixed the problem

winpty docker exec -it <containerIdOrName> bash

docker exec runs a new command in an already-running container. It is not the way to start a new container -- use docker run for that.

That may be the cause for the "non tty input" error. Or it could be where you are running docker. Is it a true terminal? That is, is a full tty session available? You might want to check if you are in an interactive session with

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


I encountered this same error message in Windows 7 64bit using Mintty shipped with Git for Windows. $docker run -i -t ubuntu /bin/bash cannot enable tty mode on non tty input

I tried to prefix the above command with winpty as other answers suggested 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 happened 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:/#

I'm running docker exec -it under jenkins jobs and getting error 'cannot enable tty mode on non tty input'. No output to docker exec command is returned. My job login sequence was:

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

I made a change to use -T flag in the initial ssh from jenkins. "-T - Disable pseudo-terminal allocation". And use -i flag with docker exec instead of -it. "-i - interactive. -t - allocate pseudo tty.". This seems to have solved my problem.

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

Behaviour kindof matches this docker exec tty bug: Workaround on that docker bug discussion suggests using this:

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

Using that workaround didn't solve my problem. It is interesting though. Try these using different flags and under different ssh invocations, you can see 'not a tty' even with using -t with docker exec:

$ docker exec -it <CONTAINER> script -qc 'tty'
$ docker exec -it <CONTAINER> 'tty'            
not a tty
$ docker exec -it <CONTAINER> bash -c 'tty' 
not a tty

Need Your Help

What is the equivalent of "!=" in Excel VBA?

function syntax excel-vba inequality vba

The problem is that != does not work as a function in excel vba.

Can I embed a custom font in an iPhone application?

ios cocoa-touch fonts

This question relates to iOS pre-3.2. As of 3.2, this functionality is easily achievable using samvermette's answer below, and I have changed the Accepted Answer (from command to samvermette) to re...