title: How to install Python on nodejs Docker image
body: <p>I have a nodejs application that works on my machine since I have python installed and it's in the global env PATH (also in process.env.PATH) so I can run:</p>
  
  <pre><code>const spawn = require("child_process").spawn;
   console.log('PATH:::::');
   console.log(process.env.PATH);
   const pythonProcess = spawn('python', ["./detect_shapes.py", './example2.png']);
   pythonProcess.stdout.on('data', (data) =&gt; {
   console.log('DATA::::');
   console.log(data);
   res.render('index', {data});
  });
  </code></pre>
  
  <p>The script above basically runs a separate python script inside my nodejs application and returns a response to it. I can run the basic commands that can be found on any machine like this: <code>const pythonProcess = spawn('ls');</code>. This line of code will run the ls command and return the files as it is expected to do.</p>
  
  <p>I also have a <code>Dockerfile</code> like this:</p>
  
  <pre><code>FROM node:9-slim
  WORKDIR /app 
  COPY . /app 
  RUN npm install 
  EXPOSE 3000 
  CMD ["node", "index.js"]
  </code></pre>
  
  <p>I created nodejs applications with this exact Dockerfile config and it worked, since I am using child_process.spawn functions it maybe doesn't know about python or it's path so I am getting this error:</p>
  
  <pre><code>Error: spawn python ENOENT
   at Process.ChildProcess._handle.onexit (internal/child_process.js:201:19)
   at onErrorNT (internal/child_process.js:379:16)
   at process._tickCallback (internal/process/next_tick.js:178:19)
  Emitted 'error' event at:
   at Process.ChildProcess._handle.onexit (internal/child_process.js:207:12)
   at onErrorNT (internal/child_process.js:379:16)
   at process._tickCallback (internal/process/next_tick.js:178:19)
  </code></pre>
  
  <p>I tried adding a <code>RUN apt-get install python -y</code> in my Dockerfile for it to install python in my docker image and I can use python, but it doesn't work. Do I have to add another <code>FROM &lt;image&gt;</code> that can install python (I am thinking that node:9-slim doesn't know how to install python since it's not used for that) in the Dockerfile so docker knows how to download python so I can use it.</p>
  
  <p>Also when I print <code>process.env.PATH</code> on my docker container I get this: <code>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin</code>. How can I know that I have python working on my image and/or how can I add it to my paths if that is the problem?</p>
  
  <p>I am new to Docker. I learned it yesterday, so if I didn't make things clear or you need more information please PM me or leave a comment.</p>