docker exec -it returns “cannot enable tty mode on

2019-01-13 04:07发布

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" 

标签: centos docker
8条回答
叛逆
2楼-- · 2019-01-13 04:51

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.

查看更多
Explosion°爆炸
3楼-- · 2019-01-13 04:55

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'

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

查看更多
登录 后发表回答