title: Why is my node child_process terminating early?
body: <p>I am trying to run an async node child_process which runs a docker container.</p>
  
  <pre><code>let runDockerCmd = `docker-compose -f ./vm/docker-compose.yml run --rm vm node temp.js`;
  child_process.exec(runDockerCmd, (error, stdout, stderr) =&gt; {
    if (error) {
      console.error(`exec error: ${error}`);
      return;
    }
    console.log(`stdout: ${stdout}`);
    console.log(`stderr: ${stderr}`);
  });
  </code></pre>
  
  <p>Where temp.js contains a <code>for loop</code>. Sometimes it runs half the loop, sometimes a third etc. then it terminates.</p>
  
  <p>I can get it to work using <code>child_process.execSync</code> but that is a bit unsavoury. Why does it exit like that, and how do I keep it alive?</p>