title: Node.js spawn process not working inside Docker container
body: <p>I have a server.js file in Node that calls python scripts as follows: </p>
  
  <pre><code>// call python scripts 
  var spawn = require("child_process").spawn;
  var process = spawn('python',["test.py", function_args]);
  
  process.stdout.on('data', function (data){
      res.json({
         "answer" : from_python
      })
  }); 
  </code></pre>
  
  <p>This works perfectly when simply running node as usual: </p>
  
  <pre><code>node server.js 
  </code></pre>
  
  <p>But when I place everything inside a docker container, the application never enters the process.stdout.on </p>
  
  <p>Everything else works perfectly. I can serve static files, call express endpoints, etc. It is just the process that is not getting called. </p>
  
  <p>I have tried placing child_process inside my package.json file as a dependency. </p>
  
  <p>Here is my Dockerfile:</p>
  
  <pre><code>FROM node:carbon
  
  # Create app directory
  WORKDIR /usr/src/app
  
  # Install app dependencies
  # A wildcard is used to ensure both package.json AND package-lock.json are copied
  COPY package*.json ./
  
  RUN npm install
  
  # Bundle app source
  COPY . .
  
  EXPOSE 80
  CMD ["npm","start"]
  </code></pre>
  
  <p>This is my package.json file: </p>
  
  <pre><code>{
    "name": "my_app_name",
    "version": "1.0.0",
    "description": "my_desc",
    "author": "my_name",
    "main": "server.js",
    "scripts": {
      "start": "node server.js"
    },
    "dependencies": {
      "express": "^4.16.2",
      "path": "^0.12.7",
      "fs": "^0.0.1-security",
      "child_process": "^1.0.2"
    }
  }
  </code></pre>
  
  <p>Note that running server.js is not the problem. This file runs the other pieces such as serving static files and exposing express endpoints. The problem seems to just be with the child_process not running. It is not that Python isn't getting called, it is that node will not even enter the process part of server.js. </p>
  
  <p>Also note that the Python prints its output via stdout. Not sure of docker has an issue registering standard outputs. </p>