Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

centos

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" 
like image 569
user2118095 Avatar asked Mar 31 '15 23:03

user2118095


4 Answers

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
like image 135
Stéphane Bruckert Avatar answered Nov 16 '22 04:11

Stéphane Bruckert


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

like image 42
Senthil Avatar answered Nov 16 '22 02:11

Senthil


just use "-i"

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

like image 39
Mr.Thanks Avatar answered Nov 16 '22 03:11

Mr.Thanks


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.

EDIT:

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.

like image 23
alvinc Avatar answered Nov 16 '22 03:11

alvinc