How to install python and other pre-requisites for node-red-contrib-machine-learning-v2 on a docker container


I need to install these dependencies in advance, I am using docker to install nodered, how to install these dependencies, is there an easy way.
thanks!

Is this a duplicate of How to install the required dependencies ?

node-red-contrib-machine-learning-v2 (node) - Node-RED

Hi @lei1 this is not really node-red question & this not a docker forum.

Your options are (as far i can see)...

  • ask on stackoverlfow or a docker forum
  • learn how to create custom images.
  • give up on docker and install to the OS
  • wait and hope someone will come along and be nice enough & competent to help with this non-node-red question

PS, this is a duplicate thread. Please dont double post.

@Steve-Mcl I don't think it is unreasonable to ask for help installing Node-RED node in the Node-RED provided docker image. This is not a 'non-node-red' question.

@lei1 this is definitely an area our docs don't provide a lot of help with, so it does currently require a good knowledge of Docker and how to build containers.
I can't give you some immediate help on it right now... but I've asked someone who knows more Docker than I do to take a look and respond to your question.

Ok, my apologies, I considered this non node-red as it was an issue particular to a contrib node with pre-reqs outside of the core node-red setup.

Noted for future :+1

thank you so much

Hi @lei1

I have a blog post I've been working on but it's not quite ready to publish just yet, but here is section of it that I hope should help.


As well as the pre-built containers the node-red-docker project on github also contains the Dockerfile and scripts to build a version of the Node-RED Docker container based on the Debian Linux distribution. This uses the normal glibc library and also being a mainstream Linux distribution it is more likely to be used as the basis for instructions for install many libraries and pre-requisites for NodeJS nodes.

You can build the container locally by running the following commands:

$ git clone https://github.com/node-red/node-red-docker.git
$ cd node-red-docker /docker-custom
$ ./docker-debian.sh

This will build a container image called testing:node-red-build by default and which can be run as follows:

$ docker run -d -p 1880:1880 -v node_red_data:/data --name myNRtest testing:node-red-build

Now you have a debian based container it can either be used as the base for a new Dockerfile which can be used to add in any prerequisite libraries or applications.

For example to install the prerequisite libraries for node-red-contrib-machine-learning node the following Dockerfile will extend the output of the previous command and add the required python libraries.

FROM testing:node-red-build
USER root
RUN apt-get install -y python3-pip python3-numpy python3-pandas 
RUN pip install scikit-learn tensorflow
USER node-red

Another approach would be to edit the Dockerfile.debian found in the docker-custom directory mentioned earlier.

...
COPY --from=build /usr/src/node-red/prod_node_modules ./node_modules
# Chown, install devtools & Clean up

RUN chown -R node-red:root /usr/src/node-red && \
    apt-get update && apt-get install -y build-essential python-dev python3 \ 
    python3-pip python3-numpy python3-pandas && \
    pip install scikit-learn tensorflow && \
    rm -r /tmp/*
USER node-red
...
1 Like

Thank you very much for your help, it was so useful for me, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.