How to workaround “the input device is not a TTY” when using grunt-shell to invoke a script that calls docker run?

烂漫一生 提交于 2019-11-29 01:05:42
BMitch

Remove the -t from the docker run command:

docker run $RUN_ENV_FILE -i --rm --user node -v "$PWD":/app -w /app yaktor/node:0.39.0 $@

The -t tells docker to configure the tty, which won't work if you don't have a tty and try to attach to the container (default when you don't do a -d).

docker_newbie

This solved an annoying issue for me. The script had these lines:

docker exec **-it**  $( docker ps | grep mysql | cut -d' ' -f1)  mysql --user= ..... > /var/tmp/temp.file
mutt -s "File is here" someone@somewhere.com < /var/tmp/temp.file

The script would run great if run directly and the mail would come with the correct output. However, when run from cron, (crontab -e) the mail would come with no content. Tried many things around permissions and shells and paths etc. However no joy!

Finally found this:

*/20 * * * * scriptblah.sh > $HOME/cron.log 2>&1

And on that cron.log file found this output:

the input device is not a TTY

Search led me here. And after I removed the -t, it's working great now!

docker exec **-i**  $( docker ps | grep mysql | cut -d' ' -f1)  mysql --user= ..... > /var/tmp/temp.file
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!