Node-RED on Docker
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?
- 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.
Simply start Node-RED and access it via
$ 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
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
NODE_RED_USER_DIR: The directory where all user data is stored. This translates to
settings.js. In most cases it makes sense to keep the
Example: Starting Node-RED with
my_flow.json from the host data directory
$ 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
Note: Node.js will also respect its own
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
/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
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_CACHE environment variables.
1880: The default port where Node-RED is listening. Can be changed via
If you have any questions don't hesitate to join us on Slack.