Docker Community Forums

Share and learn in the Docker community.

How to run scripts (node.js) via python (django) in container?


(Zurek) #1

Hi. I am programming project in django and i must run node script in therelike this:

os.system("node face-detection.js logged.png")

When i run this command normally in my linux os its working but my container cannot recognize node please how will i install node js to my container and be able to run scripts like this?

node -v: v9.9.0
npm -v: 5.8.0

My Dockerfile:

FROM python:3.4

# Ensure that Python outputs everything that's printed inside
# the application rather than buffering it.
ENV PYTHONUNBUFFERED 1

# Creation of the workdir
RUN mkdir /code
WORKDIR /code

# Add requirements.txt file to container
ADD requirements.txt /code/

# Install requirements
RUN pip install --upgrade pip
RUN pip install -r /code/requirements.txt

# Add the current directory(the web folder) to Docker container
ADD . /code/

My docker-compose.yml:

version: "3"

services:

  web:
    build: ./web/
    ports:
      - "8001:8001"
    volumes:
      - ./web:/code
      - /home/cosmo62d/db_data/db.sqlite3:/code/db.sqlite3
    command: python manage.py runserver 0.0.0.0:8001

view.py where i want to run the command: os.system("node face-detection.js logged.png")
Error when i triying to run that script in my container: sh: 1: node: not found
Can someone please explain me how to run that? Many thanks.