Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker exec command not executing in sh file

Tags:

docker

When running below command in command line(terminal) this gets executed fine:

$sudo docker exec -it 5570dc09b58 bash

But same results with :

FATA[0000] cannot enable tty mode on non tty input

Error when running in a shell script file.

like image 764
Priya Dharshini Avatar asked Sep 01 '25 17:09

Priya Dharshini


2 Answers

Scripts may be forced to run in interactive mode with the -i option or with a #!/bin/bash -i header.

So adding shebang to the script with -i option should work:

#!/bin/bash -i

docker exec -it ed3d9e46b8ee date

Run the script as usual:

chmod +x run.sh
sudo ./run.sh 

Output:

Thu Apr  2 14:06:00 UTC 2015
like image 78
Vor Avatar answered Sep 04 '25 07:09

Vor


You are not running docker in a terminal, so you should remove -t from -it:

sudo docker exec -i 5570dc09b58 bash

See a more detailed answer here.

like image 38
Stéphane Bruckert Avatar answered Sep 04 '25 09:09

Stéphane Bruckert