Skip to content

Commit

Permalink
- fixed issues node-red#19, except 5
Browse files Browse the repository at this point in the history
  • Loading branch information
RaymondMouthaan committed Sep 24, 2019
1 parent 0ec4f52 commit 3feeb36
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ language: bash

env:
global:
- TARGET=nodered/node-red-docker
- TARGET=nodered/node-red
- QEMU_VERSION=v4.0.0
- OS=alpine
- DOCKER_FILE=Dockerfile.alpine
Expand Down
90 changes: 45 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# Node-RED-Docker
# Node-RED Docker

[![Greenkeeper badge](https://badges.greenkeeper.io/node-red/node-red-docker.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/node-red/node-red-docker.svg?branch=master)](https://travis-ci.org/RaymondMouthaan/node-red)
[![DockerHub Pull](https://img.shields.io/docker/pulls/nodered/node-red-docker.svg)](https://hub.docker.com/r/nodered/node-red-docker/)
[![DockerHub Pull](https://img.shields.io/docker/pulls/nodered/node-red-docker.svg)](https://hub.docker.com/r/nodered/node-red/)

This project describes some of the many ways Node-RED can be run under Docker and has support for multiple architectures (amd64, arm32v6, arm32v7 and arm64v8).
Some basic familiarity with Docker and the [Docker Command Line](https://docs.docker.com/engine/reference/commandline/cli/) is assumed.

This project also provides the build for the `nodered/node-red-docker` container on [Docker Hub](https://hub.docker.com/r/nodered/node-red-docker/).
This project also provides the build for the `nodered/node-red` container on [Docker Hub](https://hub.docker.com/r/nodered/node-red/).

## Quick Start
To run this directly in Docker at it's simplest just run:

docker run -it -p 1880:1880 --name mynodered nodered/node-red-docker
docker run -it -p 1880:1880 --name mynodered nodered/node-red

Let's dissect that command:

docker run - run this container... and build locally if necessary first.
-it - attach a terminal session so we can see what is going on
-p 1880:1880 - connect local port 1880 to the exposed internal port 1880
--name mynodered - give this machine a friendly local name
nodered/node-red-docker - the image to base it on - currently Node-RED v0.20.8
nodered/node-red - the image to base it on - currently Node-RED v0.20.8


Running that command should give a terminal window with a running instance of Node-RED.
Expand Down Expand Up @@ -127,29 +127,29 @@ The following table shows the variation of provided Node-RED images.
## Manifest Lists
The following table shows the provided Manifest Lists.

| **Tag** | **Node-RED Base Image** |
|----------------------------------------|---------------------------------------------------|
| latest, 0.20.8, | nodered/node-red-docker:0.20.8-10-amd64 |
| latest-10, 0.20.8-10 | nodered/node-red-docker:0.20.8-10-arm32v6 |
| | nodered/node-red-docker:0.20.8-10-arm32v7 |
| | nodered/node-red-docker:0.20.8-10-arm64v8 |
| | |
| latest-minimal, 0.20.8-minimal, | nodered/node-red-docker:0.20.8-10-amd64-minimal |
| latest-10-minimal, 0.20.8-10-minimal | nodered/node-red-docker:0.20.8-10-arm32v6-minimal |
| | nodered/node-red-docker:0.20.8-10-arm32v7-minimal |
| | nodered/node-red-docker:0.20.8-10-arm64v8-minimal |

| **Tag** | **Node-RED Base Image** |
|----------------------------------------|---------------------------------------------------|
| latest-12, 0.20.8-12 | nodered/node-red-docker:0.20.8-12-amd64 |
| | nodered/node-red-docker:0.20.8-12-arm32v6 |
| | nodered/node-red-docker:0.20.8-12-arm32v7 |
| | nodered/node-red-docker:0.20.8-12-arm64v8 |
| | |
| latest-12-minimal, 0.20.8-12-minimal | nodered/node-red-docker:0.20.8-12-amd64-minimal |
| | nodered/node-red-docker:0.20.8-12-arm32v6-minimal |
| | nodered/node-red-docker:0.20.8-12-arm32v7-minimal |
| | nodered/node-red-docker:0.20.8-12-arm64v8-minimal |
| **Tag** | **Node-RED Base Image** |
|----------------------------------------|--------------------------------------------|
| latest, 0.20.8, | nodered/node-red:0.20.8-10-amd64 |
| latest-10, 0.20.8-10 | nodered/node-red:0.20.8-10-arm32v6 |
| | nodered/node-red:0.20.8-10-arm32v7 |
| | nodered/node-red:0.20.8-10-arm64v8 |
| | |
| latest-minimal, 0.20.8-minimal, | nodered/node-red:0.20.8-10-amd64-minimal |
| latest-10-minimal, 0.20.8-10-minimal | nodered/node-red:0.20.8-10-arm32v6-minimal |
| | nodered/node-red:0.20.8-10-arm32v7-minimal |
| | nodered/node-red:0.20.8-10-arm64v8-minimal |

| **Tag** | **Node-RED Base Image** |
|----------------------------------------|--------------------------------------------|
| latest-12, 0.20.8-12 | nodered/node-red:0.20.8-12-amd64 |
| | nodered/node-red:0.20.8-12-arm32v6 |
| | nodered/node-red:0.20.8-12-arm32v7 |
| | nodered/node-red:0.20.8-12-arm64v8 |
| | |
| latest-12-minimal, 0.20.8-12-minimal | nodered/node-red:0.20.8-12-amd64-minimal |
| | nodered/node-red:0.20.8-12-arm32v6-minimal |
| | nodered/node-red:0.20.8-12-arm32v7-minimal |
| | nodered/node-red:0.20.8-12-arm64v8-minimal |

With the support of Docker manifest list, there is no need to explicit add the tag for the architecture to use.
When a docker run command or docker service command or docker stack command is executed, docker checks which architecture is required and verifies if it is available in the docker repository. When it does, docker pulls the matching image for it.
Expand All @@ -158,7 +158,7 @@ Therefor all tags regarding Raspberry PI's are dropped.

For example: suppose you are running on a Raspberry PI 3B, which has arm32v7 as architecture. Then just simple run the following command to pull the image (tagged by `0.20.8-10-arm32v7`) and run the container.
```
docker run -it -p 1880:1880 --name mynodered nodered/node-red-docker:latest
docker run -it -p 1880:1880 --name mynodered nodered/node-red:latest
```

The same command can be used for running on an amd64 system, since docker discovers its running on a amd64 host and pulls the image with matching tag (`0.20.8-10-amd64`).
Expand Down Expand Up @@ -191,7 +191,7 @@ But to allow access to this host directory, the node-red user (default uid=1001)
To override the default uid and gid of the node-red user inside the the container you can use the option `--user="<my_host_uid>:<my_host_gid>"`:

```
$ docker run -it --user="<my_host_uid>:<my_host_gid>" -p 1880:1880 -v <host_directory>:/data --name mynodered nodered/node-red-docker
$ docker run -it --user="<my_host_uid>:<my_host_gid>" -p 1880:1880 -v <host_directory>:/data --name mynodered nodered/node-red
```

Example:
Expand Down Expand Up @@ -228,7 +228,7 @@ uid=1000(pi) gid=1000(pi) [...]

- So the final command becomes:
```
$ docker run -it --user="1000:1000" -p 1880:1880 -v ~/.node-red:/data --name mynodered nodered/node-red-docker
$ docker run -it --user="1000:1000" -p 1880:1880 -v ~/.node-red:/data --name mynodered nodered/node-red
```

Running a Node-RED container with a host directory mounted as the data volume,
Expand Down Expand Up @@ -265,7 +265,7 @@ version: 3.7
services:
node-red:
image: nodered/node-red-docker:latest
image: nodered/node-red:latest
environment:
- TZ=Europe/Amsterdam
ports:
Expand Down Expand Up @@ -322,13 +322,13 @@ The flows configuration file is set using an environment parameter (**FLOWS**),
which defaults to *'flows.json'*. This can be changed at runtime using the
following command-line flag.

$ docker run -it -p 1880:1880 -e FLOWS=my_flows.json nodered/node-red-docker
$ docker run -it -p 1880:1880 -e FLOWS=my_flows.json nodered/node-red

Node.js runtime arguments can be passed to the container using an environment
parameter (**NODE_OPTIONS**). For example, to fix the heap size used by
the Node.js garbage collector you would use the following command.

$ docker run -it -p 1880:1880 -e NODE_OPTIONS="--max_old_space_size=128" nodered/node-red-docker
$ docker run -it -p 1880:1880 -e NODE_OPTIONS="--max_old_space_size=128" nodered/node-red

## Adding Nodes

Expand Down Expand Up @@ -376,7 +376,7 @@ This Dockerfile builds a custom Node-RED image with the flightaware module
installed from NPM.

```
FROM nodered/node-red-docker
FROM nodered/node-red
RUN npm install node-red-contrib-flightaware
```

Expand Down Expand Up @@ -426,34 +426,34 @@ container using this volume.
$ docker volume ls
DRIVER VOLUME NAME
local node_red_user_data
$ docker run -it -p 1880:1880 -v node_red_user_data:/data --name mynodered nodered/node-red-docker
$ docker run -it -p 1880:1880 -v node_red_user_data:/data --name mynodered nodered/node-red

Using Node-RED to create and deploy some sample flows, we can now destroy the
container and start a new instance without losing our user data.

$ docker rm mynodered
$ docker run -it -p 1880:1880 -v node_red_user_data:/data --name mynodered nodered/node-red-docker
$ docker run -it -p 1880:1880 -v node_red_user_data:/data --name mynodered nodered/node-red

## Updating

Updating the base container image is as simple as

$ docker pull nodered/node-red-docker
$ docker pull nodered/node-red
$ docker stop mynodered
$ docker start mynodered

## Running headless

The barest minimum we need to just run Node-RED is

$ docker run -d -p 1880 nodered/node-red-docker
$ docker run -d -p 1880 nodered/node-red

This will create a local running instance of a machine - that will have some
docker id number and be running on a random port... to find out run

$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4bbeb39dc8dc nodered/node-red-docker:latest "npm start" 4 seconds ago Up 4 seconds 0.0.0.0:49154->1880/tcp furious_yalow
4bbeb39dc8dc nodered/node-red:latest "npm start" 4 seconds ago Up 4 seconds 0.0.0.0:49154->1880/tcp furious_yalow
$

You can now point a browser to the host machine on the tcp port reported back, so in the example
Expand All @@ -465,13 +465,13 @@ You can link containers "internally" within the docker runtime by using the --li

For example I have a simple MQTT broker container available as

docker run -it --name mybroker nodered/node-red-docker
docker run -it --name mybroker nodered/node-red

(no need to expose the port 1883 globally unless you want to... as we do magic below)

Then run nodered docker - but this time with a link parameter (name:alias)

docker run -it -p 1880:1880 --name mynodered --link mybroker:broker nodered/node-red-docker
docker run -it -p 1880:1880 --name mynodered --link mybroker:broker nodered/node-red

the magic here being the `--link` that inserts a entry into the node-red instance
hosts file called *broker* that links to the mybroker instance.... but we do
Expand All @@ -494,7 +494,7 @@ Here is a list of common issues users have reported with possible solutions.
If you are seeing *permission denied* errors opening files or accessing host devices, try running the container as the root user.

```
docker run -it -p 1880:1880 --name mynodered --user=root nodered/node-red-docker
docker run -it -p 1880:1880 --name mynodered --user=root nodered/node-red
```

References:
Expand All @@ -508,7 +508,7 @@ https://github.com/node-red/node-red/issues/8
If you want to access a device from the host inside the container, e.g. serial port, use the following command-line flag to pass access through.

```
docker run -it -p 1880:1880 --name mynodered --device=/dev/ttyACM0 nodered/node-red-docker
docker run -it -p 1880:1880 --name mynodered --device=/dev/ttyACM0 nodered/node-red
```
References:
https://github.com/node-red/node-red/issues/15
Expand All @@ -518,7 +518,7 @@ https://github.com/node-red/node-red/issues/15
If you want to modify the default timezone, use the TZ environment variable with the [relevant timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).

```
docker run -it -p 1880:1880 --name mynodered -e TZ=Europe/London nodered/node-red-docker
docker run -it -p 1880:1880 --name mynodered -e TZ=Europe/London nodered/node-red
```

References:
Expand Down
2 changes: 1 addition & 1 deletion docker-custom/Dockerfile.custom
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG OS=alpine
FROM ${ARCH}/node:${NODE_VERSION}-${OS} AS base

# Copy scripts
COPY .docker/scripts/*.sh /tmp/
COPY scripts/*.sh /tmp/

# Install tools, create Node-RED app and data dir, add user and set rights
RUN set -ex && \
Expand Down
6 changes: 3 additions & 3 deletions docker-custom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Change the build arguments as needed:
- `--build-arg BUILD_DATE="$(date +"%Y-%m-%dT%H:%M:%SZ")"` : don't change this
- `--build-arg TAG_SUFFIX=default` : to build the default or minimal image
- `--file Dockerfile.custom` : Dockerfile to use to build your image.
- `--tag mynodered:node-red-custom-build` : set the image name and tag
- `--tag testing:node-red-build` : set the image name and tag

## 3. **Run docker-make.sh**

Expand All @@ -49,7 +49,7 @@ This starts building your custom image and might take a while depending on the s
When building is done you can run the custom image by the following command:

```shell script
$ docker run -it -p1880:1880 mynodered:node-red-custom-build
$ docker run -it -p1880:1880 testing:node-red-build
```

With the following command you can verify your docker image:
Expand All @@ -60,5 +60,5 @@ $ docker inspect testing:node-red-build

## 4. **Advanced Configuration**

`Dockerfile.custom` can be modified as required. To add more applications the `install_devtools.sh` can be modified as needed.
`Dockerfile.custom` can be modified as required. To add more applications the `scripts/install_devtools.sh` can be modified as needed.

2 changes: 1 addition & 1 deletion docker-custom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"node-red": "0.20.8"
},
"engines": {
"node": "8.*.*"
"node": ">=10"
}
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@
}
],
"dependencies": {
"node-red": "0.20.8",
"node-red-node-tail": "^0.0.3"
"node-red": "0.20.8"
},
"engines": {
"node": ">=8"
"node": ">=10"
}
}

0 comments on commit 3feeb36

Please sign in to comment.