This repo was created to demonstrate an issue when trying to communicate with processes launched
with docker run
, where they have been spawned from a Node.js process using extra stdio pipes:
child = spawn(
"/usr/bin/env",
[
"node",
"ponger.js"
],
{
stdio: ['ignore', 'inherit', 'inherit', 'pipe', 'pipe']
}
);
These processes work as expected when running on the host machine, but the pipes are not set up
properly when using docker run
:
child = spawn(
"/usr/bin/env",
[
"docker",
"run",
"--rm",
"--init",
"--ipc=host",
`-v=${ __dirname }:/usr/app`,
"node:latest",
"node",
"/usr/app/ponger.js"
],
{
stdio: ['ignore', 'inherit', 'inherit', 'pipe', 'pipe']
}
);
A Stack Overflow question has been created to gather potential solutions to this problem.
The example uses a Jest test suite to demonstrate the behaviour on both the host machine and the docker container. Simply run the following to get it to work:
npm install
npm test