Sign inSign up

jodok/node-red

By jodok

Updated almost 10 years ago

Node-RED - A visual tool for wiring the Internet of Things

Image
0

309

jodok/node-red repository overview

Node-RED on Docker

This repository holds a build definition and supporting files for building a Docker image to run Node-RED. It is published as automated build machine-data/node-red on Docker Hub.

What is Node-RED?

Node-RED is a tool for wiring together hardware devices, APIs and online services in new and interesting ways.

Yet another Node-RED container?

Not quite:

  • Based on the official Alpine Linux image - super slim and lightweight.
  • Only node.js and node-gyp as dependency (needed by some add-on packages).
  • No magic. Straight config that follows upstream. Simple and clean configuration via environment variables or config file.
  • Image follows Dockerfile best practices (dropping root privileges, PID1 for proper signalling, logging,...)
  • All user data under /data - ready-to mount.

Quickstart

Simply start Node-RED and access it via http://{HOSTNAME}:1880:

$ docker run -d -p 1880:1880 machine-data/node-red

Application data (flows and add-on modules) is being stored in /data, therefore it is recommended to bind mount a volume.

$ mkdir data
$ docker run -d \
	--volume $(pwd)/data:/data \
	--publish 1880:1880 \
	machine-data/node-red

Environment variables

It is very easy to configure Node-RED via environment variables. If no config file is present, the docker-entrypoint.sh script will create one based on sane defaults and environment variables.

  • NODE_RED_FLOW_FILE: The file containing the flows. If not set, the image defaults flowFile to flows.json.

  • NODE_RED_USER_DIR: The directory where all user data is stored. This translates to userDir in settings.js. In most cases it makes sense to keep the /data default.

-- Example: Starting Node-RED with my_flow.json from the host data directory /mnt/data/nodered/:

$ mkdir -p /mnt/data/flows
$ touch /mnt/data/flows/my_flow.json
$ docker run -d \
             -e NODE_RED_FLOW_FILE=my_flow.json \
             -v /mnt/data/flows:/data \
             -p 1880:1880 machine-data/node-red

will start Node-RED with the myflow.json flow.

Note: Node.js will also respect its own NPM_CONFIG_ variables.

Configuration file

The container is configured to start Node-RED with /config/settings.js as config file. If a config file is mounted (preferably read-only), the NODE_RED_ environment variables will be ignored:

$ curl -O https://raw.githubusercontent.com/node-red/node-red/master/settings.js
$ sed -i -e "s#//userDir: '.*'#userDir: '/data'#" settings.js
$ docker run -d \
             -v $(pwd)/settings.js:/config/settings.js:ro \
             -p 1880:1880 machine-data/node-red

Volumes

  • /data: Path where Node-RED's data is stored (userDir in Node-RED configuration). Packages that are installed via the webinterface will be stored in /data/node_modules.

When installing additional packages the npm installer will create a download cache under /tmp/.npm and further temp files in /tmp/.npm-*. You might want to bind mount your local temporary directory. To change these paths you need to overwrite the NPM_CONFIG_TMP and NPM_CONFIG_CACHE environment variables.

Ports

  • 1880: The default port where Node-RED is listening. Can be changed via $PORT environment variable.

Node-RED is a creation of IBM Emerging Technology, authored by Nick O'Leary and Dave Conway-Jones. Copyright 2013, 2016 IBM Corp. under the Apache 2.0 license.

docker-node-red is licensed under the Apache 2.0 license, was created by Jodok Batlogg. Copyright 2016 Crate.io, Inc..

Contributing

Thanks for considering contributing to docker-node-red! The easiest way to contribute is either by filing an issue on Github or to fork the repository to create a pull request.

If you have any questions don't hesitate to join us on Slack.

Tag summary

Content type

Image

Digest

Size

76.2 MB

Last updated

almost 10 years ago

docker pull jodok/node-red