Docker Community Forums

Share and learn in the Docker community.

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

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.

# Creation of the workdir
RUN mkdir /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"


    build: ./web/
      - "8001:8001"
      - ./web:/code
      - /home/cosmo62d/db_data/db.sqlite3:/code/db.sqlite3
    command: python runserver 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.

1 Like

HI, @zurek, did you happen to find a solution to this problem? I’m just in the very same situation, but I have no clue on how to manage to solve it.

Thanks in advance for reading!


João Pedro R. Mattos

1 Like