RasPi ZeroでNode-RedをDockerで実行する


Node-RedをDockerで実行する

関連パッケージのインストール

パッケージ名 説明
apt-transport-https aptでhttpsを使えるようにする。
ca-certificates
software-properties-common
$ sudo apt remove docker docker-engine docker.io
$ sudo dpkg -l docker*
$ sudo dpkg -P docker-ce docer-ce-cli
$ sudo apt update
$ sudo apt install apt-transport-https ca-certificates curl software-properties-common

Dockerのインストール

Raspberry pi 4 MODEL B(raspbian buster)でも同様の手順でOK

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sh get-docker.sh 

Dockerを一般ユーザで実行する

$ sudo usermod -aG docker $USER

Dockerの動作確認

$ docker --version
Docker version 19.03.13, build 4484c46


$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
4ee5c797bcd7: Pull complete 
Digest: sha256:4cf9c47f86df71d48364001ede3a4fcd85ae80ce02ebad74156906caff5378bc
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (arm32v7)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Node-Redの実行

https://hub.docker.com/r/nodered/node-red/

$ docker run -it -p 1880:1880 -v node_red_user_data:/data --name mynodered nodered/node-red:1.0.1-10-minimal-arm32v6

ターミナルに再接続する(ログを確認する)ためには、以下を実行します:

$ docker attach mynodered

OTG Ether net

$ nmcli c add type ethernet con-name raspi-usb ifname enp0s20f0u9
$ nmcli c modify raspi-usb ipv4.method shared
$ nmcli c up raspi-usb
$ nmcli d show raspi-usb

dockerのubuntu18.04にNodeRedをインストールする

nodeのインストール

https://qiita.com/seibe/items/36cef7df85fe2cefa3ea

NodeRedのインストール

sudo npm install -g --unsafe-perm node-red

NodeRes ROS

https://flows.nodered.org/node/node-red-contrib-ros
```
npm install -g --unsafe-perm node-red-admin