I'm trying to use script
as the entrypoint of a docker container to log everything that happens in that container to a file on a mounted volume. It works great if there is a tty:
$ docker run -t --rm --privileged -v $PWD:/log rhel7:7.7 /usr/bin/script /log/out.script --timing=/log/out.timing -f -e -c 'echo "hello world"; sleep 10; echo "goodbye world"'
Last login: Tue Jan 21 00:45:14 UTC 2020 on pts/41
Script started, file is /log/out.script
hello world
goodbye world
Script done, file is /log/out.script
However, if I remove the TTY, script doesn't execute any of the '-c' commands:
$ docker run --rm --privileged -v $PWD:/log rhel7:7.7 /usr/bin/script /log/out.script --timing=/log/out.timing -f -e -c 'echo "hello world"; sleep 10; echo "goodbye world"'
Last login: Tue Jan 21 00:50:39 UTC 2020 on pts/41
Script started, file is /log/out.script
Script done, file is /log/out.script
$ ls -s out.*
0 out.script 0 out.timing
Unfortunately, the environment I plan on running in will not have TTYs for containers. What is reason for script behaving this way? Is there a way around it?
script
program you're using: I've tried it with a simple container with justbusybox
,script
and the needed libs, and it works OK with or without-t
. – Jan 21 '20 at 02:34