'Unable to output `docker exec` to file with `tee`

The following command works perfectly when I run it manually from my CLI.

docker exec -it my_container npm run test | tee results.txt

The result is that I see the output of npm run test in both my computer screen and the output is also saved to the file results.txt.

When I run this same command as a "GitHub Workflow Step", I get the error message:

The input device is not a TTY

So I dropped the t from my command like this:

docker exec -i my_container npm run test | tee results.txt

But now the problem is that my results.txt does not have any of the results of my npm run test.

Is there a way to run the docker exec command and output to both the screen and results.txt with a github workflow step?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source