cli
cli copied to clipboard
Feature request: allow attaching (`docker run -a`) to additional file descriptors
I'm running a command line app from a Node.js process using spawn()
. The process is launched with extra pipes in the stdio option. Here's a simplified code sample:
const stdio = ['ignore', 'pipe', 'pipe', 'pipe', 'pipe'];
const process = spawn('/path/to/command', [], { stdio });
// I can access the streams for fd3 and fd4 through the child process's `stdio` object
const { 3: pipeWrite, 4: pipeRead } = process.stdio;
pipeRead.on('data', (data) => {
if (String(data) === "PING?") {
pipeWrite.write("PONG!");
}
});
Now, this works fine but I want to run the command inside a docker container, using docker run
as the spawned executable:
const stdio = ['ignore', 'pipe', 'pipe', 'pipe', 'pipe'];
const process = spawn(
'/usr/bin/env', [
'docker',
'run',
'--rm',
'my-image',
'/path/to/command'
], { stdio }
);
This fails, the command line app inside the docker container says it cannot write to pipe. There doesn't appear to be any way to attach to these extra streams when using docker run
.