Error "Input device is not TTY"

I am running the following command from my Jenkinsfile . However, I get the error "Input device is not TTY."

 docker run -v $PWD:/foobar -it cloudfoundry/cflinuxfs2 /foobar/script.sh 

Is there a way to run a script from Jenkinsfile without interactive mode?

I basically have a file called script.sh that I would like to run inside the Docker container.

+301
docker jenkins jenkins-pipeline
Mar 29 '17 at 16:26
source share
9 answers

Remove -it from your Kli to make it non-interactive and remove TTY. If you do not need this, for example, running your command inside a Jenkins or cron script, you should do it.

Or you can change it to -i if you have an input channel to the docker command that does not come from TTY. If you have something like xyz | docker... xyz | docker... xyz | docker... xyz | docker... or docker... <input on your command line, do this.

Or you can change it to -t if you want TTY support, but don't have it on the input device. Do this for color formatting of output in your magazines or for later attachment of the container to the corresponding terminal.

Or, if you need an interactive terminal and does not work in the terminal on Linux or MacOS, use a different command line interface. PowerShell is reported to include this support on Windows.




What is TTY? This is a terminal interface that supports color output, escape sequences, cursor movement, etc., which come from the old days of mute terminals connected to mainframes. Today it is provided by Linux commands and ssh interfaces. See the Wikipedia article for more on this.

+474
Mar 29 '17 at 16:31
source share

For those struggling with this error and git bash on Windows, just use PowerShell where -it works fine.

+63
Aug 24 '17 at 19:19
source share

If you (like me) using git bash on windows, you just need to put

winpty

before your docker line:

 winpty docker exec -it some_cassandra bash 
+42
May 23 '18 at 8:52
source share

I believe that you need to be in TTY for dockers in order to be able to assign TTY (option -t ). Jenkins does not complete his assignments in TTY.

Having said that, the script that you use in Jenkins can also be run locally. In this case, it can be very convenient to have a dedicated TTY so that you can send signals, such as ctrl + c , when it is run locally.

To fix this, make your script optionally with the -t option, for example:

 test -t 1 && USE_TTY="-t" docker run ${USE_TTY} ... 
+25
Jan 12 '18 at 16:15
source share

This is not exactly what you are asking, but:

The -T key will help people using docker-compose exec!

 docker-compose -f /srv/backend_bigdata/local.yml exec -T postgres backup 
+12
Aug 19 '19 at 23:44
source share

if you use windows try with cmd, it works for me. check if docker is running.

+4
Jan 25 '18 at 2:18
source share

when using 'git bash',

1) I execute the command:

 docker exec -it 726fe4999627 /bin/bash 

I have an error:

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

2) then I execute the command:

 winpty docker exec -it 726fe4999627 /bin/bash 

I have another error:

 OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused "exec: \"D:/Git/usr/bin/ bash.exe\": stat D:/Git/usr/bin/bash.exe: no such file or directory": unknown 

3) thirdly, I perform:

 winpty docker exec -it 726fe4999627 bash 

it worked.

when I used powershell, everything worked fine.

+2
Jul 07 '19 at 13:55
source share

winpty works until you specify volumes to mount, such as ".: / mountpoint" or "$ {pwd}: / mountpoint"

The best solution I've found is to use the git-bash plugin inside Visual Code Studio and use the terminal to start and stop containers or docker-compose.

+1
Nov 07 '18 at 9:53
source share

I know that this is not a direct answer to this question, but for everyone who comes across this question who uses WSL with Docker for Windows and cmder or conemu.

The trick is not to use Docker, which is installed on Windows at / mnt / c / Program Files / Docker / Docker / resources / bin / docker.exe, but to install Docker for Ubuntu / Linux. It is worth noting that you cannot start Docker itself from WSL, but you can connect to Docker for windows from the Linux Linux client.

Install Docker on Linux

 sudo apt-get install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" sudo apt-get update sudo apt-get install docker-ce 

Connect to Docker for Windows through port 2375, which must be enabled in the settings in Docker for Windows.

docker -H localhost:2375 run -it -v/mnt/c/code: /var/app -w "/var/app" centos:7

Or set the docker_host variable, which allows you to omit the -H switch

export DOCKER_HOST=tcp://localhost:2375

You should now be able to interactively connect to the tty terminal session.

+1
Feb 26 '19 at 10:20
source share



All Articles