my $input = <STDIN>;
It is clear that this will not work in my container because there is no standard input. I want it to fail and bail out. The problem is that it never returns.
How can I detect that situation in a clean way?
If you want to detect whether the user can enter input (not directly whether it's running inside a Docker container), I'd suggest IO::Interactive, or at the very least -t STDIN. Or, you could use a prompting module instead, depending on what you're actually trying to implement.