Skip to content

Just an example of an issue when communicating with `docker run` processes spawned from Node.js

Notifications You must be signed in to change notification settings

andyearnshaw/node-docker-spawn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Running the example

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

About

Just an example of an issue when communicating with `docker run` processes spawned from Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published