Keen to mess around with Node-RED? Or you want to deploy node-red to your own docker server or Dokku and add some additional nodes?
The following solution consists of two files:
- A Dockerfile to build the container (3 Lines)
- A package.json to configure the version and some useful add-on nodes
The Dockerfile
The build is derived from an official node container (version 0.10.x).
1 2 3 |
FROM node:0.10-onbuild VOLUME /root/.node-red EXPOSE 1880 |
The configuration
The used version and the additional node are configured in the package.json. In my example below, version 0.12.1 of node-red will be installed. If you want to add other/additional nodes, just edit the dependencies block and add them.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
{ "name" : "node-red-docker", "version" : "0.12.1", "description" : "A visual tool for wiring the Internet of Things", "homepage" : "http://nodered.org", "repository" : { "type":"git", "url":"https://github.com/node-red/node-red.git" }, "main" : "node_modules/node-red/red/red.js", "scripts" : { "start": "node node_modules/node-red/red.js -v flow.json" }, "contributors": [ {"name": "Frederik Granna"} ], "dependencies": { "node-red": "0.12.1", "node-red-node-rbe": "*", "node-red-node-random": "*", "node-red-node-msgpack": "*", "node-red-node-base64": "*", "node-red-node-suncalc": "*", "node-red-node-random": "*", "node-red-node-geohash": "*", "node-red-node-mysql": "*", "node-red-contrib-blynk": "*" }, "engines": { "node": "0.10.*" } } |
The build
To build this image just put both files in one directory and run
docker build --rm -t node-red .
The start
to start your new container, just run the following command. This will bind the port 1880 to your local machine and also mount a local directory as storage for the configuration and the flows (/opt/node-red-datastore would be the directory on your docker host).
docker run -it -p 1880:1880 -v /opt/node-red-datastore:/root/.node-red node-red
Now you should be able to connect to the node red instance by opening http://<yourhost>:1880 in your browser.
Links
- My docker images: https://hub.docker.com/r/sysrun/
- https://bitbucket.org/fgranna/docker-nodered