Skip to content

Commit 8129810

Browse files
authored
Add docs about extending the standard containers (#226)
* Update Docker volume information The example on the gettings started page talks about host directories but actually creates a named volume. * Make named volume names consistent * Missed an instance of node_red_user_data * Add doc for extending Docker containers * Add link to docker-custom
1 parent d6a92ee commit 8129810

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
layout: docs-getting-started
3+
title: Adding Prerequistes to Docker
4+
toc: toc-user-guide.html
5+
slug: docker-custom
6+
redirect_from:
7+
- /docs/platforms/docker-custom
8+
---
9+
10+
### Introduction
11+
12+
The project makes available a number of different versions of the Docker container on [Docker hub](https://hub.docker.com/r/nodered/node-red/) which fall into 2 categories:
13+
14+
- Different underlying NodeJS versions. As new NodeJS LTS versions are released coresponding versions of the container are added.
15+
- Images tagged with the `-minimal` suffix. These containers are designed to contian the absolute libraries required to run Node-RED and it's core nodes.
16+
17+
Specifically the `-minimal` containers do not have the native build tools required to build some nodes components triggered by installing them.
18+
19+
Both of these sets of images are based on the NodeJS Alpine containers. Alpine is a Linux distribution tha aims to provide the smallest possible install footprint, it is used as the base for many language runtime containers (e.g. NodeJS & Python). As part of a number of optomisations to reduce the size it uses the [musl](https://www.musl-libc.org/intro.html) libc instead of the usual glibc implementation.
20+
21+
Musl works fine with most applications but on some occations it can cause problems e.g. with some of the [SAP](https://github.com/SAP/node-rfc/issues/148) nodes and with some low level video codec.
22+
23+
If you want to extend the provided Docker containers then then you will need to use Apline's package management tool `apk` to install additional libraries or applications.
24+
25+
FROM nodered/node-red:latest
26+
USER root
27+
apk add py3-pip py3-numpy py3-pandas py3-scikit-learn
28+
pip install tensorflow
29+
USER node-red
30+
31+
### Debian based containers
32+
33+
As well as the Alpine based containers the Node-RED Docker git project also includes a script to build a version of the Node-RED Docker containers based on the Debian Linux Distribution. This is useful as Debian is a more mainstream Linux distribution and many nodes include instructions on how to install prerequistes.
34+
35+
You can build the containers locally by running the following commands:
36+
37+
$ git clone https://github.com/node-red/node-red-docker.git
38+
$ cd node-red-docker/docker-custom
39+
$ ./docker-debian.sh
40+
41+
42+
This will a container called `testing:node-red-build` which can be run as follows:
43+
44+
$ docker run -d -p 1880:1880 -v node_red_data:/data --name myNRtest testing:node-red-build
45+
46+
This container can be extended to add the required prerequistes for your projects. For example to add the required libraries for the [node-red-contrib-machine-learning](https://flows.nodered.org/node/node-red-contrib-machine-learning) node the following Dockerfile will extend the previously built container.
47+
48+
FROM testing:node-red-build
49+
USER root
50+
RUN apt-get install -y python3-pip python3-numpy python3-pandas
51+
RUN pip install scikit-learn tensorflow
52+
USER node-red
53+
54+
This can be build with
55+
56+
docker build . -t custom-node-red
57+
58+
The other option is to edit the `Dockerfile.debian` to build in the dependencies up front. You can add the packages to the `apt-get` line and then add a `pip` to install the native Python modules not directly packaged for Debian.
59+
60+
...
61+
COPY --from=build /usr/src/node-red/prod_node_modules ./node_modules
62+
63+
# Chown, install devtools & Clean up
64+
RUN chown -R node-red:root /usr/src/node-red && \
65+
apt-get update && apt-get install -y build-essential python-dev python3 \
66+
python3-pip python3-numpy python3-pandas && \
67+
pip install scikit-learn tensorflow && \
68+
rm -r /tmp/*
69+
70+
USER node-red
71+
...
72+
73+
In this case you would just need to rerun the `docker-debian.sh` script.

docs/getting-started/docker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ and stop it again when required:
8787
### Image Variations
8888

8989
The Node-RED images are based on [official Node JS Alpine Linux](https://hub.docker.com/_/node/) images to keep them as small as possible.
90-
Using Alpine Linux reduces the built image size, but removes standard dependencies that are required for native module compilation. If you want to add dependencies with native dependencies, extend the Node-RED image with the missing packages on running containers or build new images see [docker-custom](https://github.com/node-red/node-red-docker/tree/master/docker-custom).
90+
Using Alpine Linux reduces the built image size, but removes standard dependencies that are required for native module compilation. If you want to add dependencies with native dependencies, extend the Node-RED image with the missing packages on running containers or build new images see [docker-custom](docker-custom) which expands on the [README.md](https://github.com/node-red/node-red-docker/tree/master/docker-custom) in the Node-RED Docker project.
9191

9292
See the [Github project README](https://github.com/node-red/node-red-docker/blob/master/README.md) for detailed Image, Tag and Manifest information.
9393

0 commit comments

Comments
 (0)