I have to say, whatever you're trying to do here seems to be the wrong way to accomplish it.

If you want a docker container to run in the background, I would think you'd want "docker create". The only advantage of "run -d" is that it doesn't exist after reboot. Is that really all you want? If you want it to only run for the duration of your perl script, then why use "-d"? You can just keep the IPC::Run instance open in the background.

Second, why run /bin/sh? You could just [ 'docker', 'run', '-d', '--name', 'xxxyyyzzz-blah', 'alpine', '/usr/bin/tail', '-f', '/dev/null' ]

Third, if you are creating this container so that you can then 'docker exec' various things in it, you probably want the '--init' option so that there is a proper PID 1 inside the container to reap processes and respond to signals.

Fourth, if your goal is, in fact, to exec things in a shared container, you might consider just running each process in its own container on a shared filesystem. Linux namespaces are fairly cheap, and the "docker-correct" way of approaching the problem is to run each process with its own "docker run" command.


In reply to Re: IPC::Run3 not working as expected when running Docker command by NERDVANA
in thread IPC::Run3 not working as expected when running Docker command by nysus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.