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

**URL:** <https://discourse.nodered.org/t/how-to-install-python-and-other-pre-requisites-for-node-red-contrib-machine-learning-v2-on-a-docker-container/47571>\
**Category:** General\
**Created:** [24 June 2021 08:54 UTC](https://discourse.nodered.org/t/how-to-install-python-and-other-pre-requisites-for-node-red-contrib-machine-learning-v2-on-a-docker-container/47571 "2021-06-24T08:54:35Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [24 June 2021 09:48 UTC](https://discourse.nodered.org/t/how-to-install-python-and-other-pre-requisites-for-node-red-contrib-machine-learning-v2-on-a-docker-container/47571/8 "2021-06-24T09:48:52Z")

</div>

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](https://github.com/node-red/node-red-docker) 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:

```auto
$ 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](https://flows.nodered.org/node/node-red-contrib-machine-learning) node the following Dockerfile will extend the output of the previous command and add the required python libraries.

```auto
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.

```auto
...
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
...

```

---

_[View the full topic](https://discourse.nodered.org/t/how-to-install-python-and-other-pre-requisites-for-node-red-contrib-machine-learning-v2-on-a-docker-container/47571)._
