Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Docker Container Started With Docker-Compose and <STDIN>

by roboticus (Chancellor)
on Sep 12, 2019 at 17:06 UTC ( #11106080=note: print w/replies, xml ) Need Help??

in reply to Docker Container Started With Docker-Compose and <STDIN>


Unless you explicitly close it, you do have an STDIN available, and the script is hanging because it's waiting for input that'll never arrive.

If the script is yours or you can change it, I'd probably try:

  • Looking for an environment variable that can indicate whether you're in the Docker container and use it to bail out of your program, or
  • Use alarm() to add a timeout for user input so it can't hang indefinitely.

If the script isn't yours, but you're using fork() to invoke the script, then you could try duplicating the STDIN stream and closing it before forking, so the child script won't have an open STDIN. That should make it immediately return with undef in $input. (That may require some jiggery-pokery with IO::Handle or maybe a double-fork, where the child of the initial fork can close its STDIN and then fork to the script you want to run.)


When your only tool is a hammer, all problems look like your thumb.

  • Comment on Re: Docker Container Started With Docker-Compose and <STDIN>

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11106080]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2020-05-27 03:45 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (152 votes). Check out past polls.