Outils pour utilisateurs

Outils du site


cours:iot:node-red_on_docker

Ceci est une ancienne révision du document !


Docker Windows Installation

Docker Login Page

Package : Docker for Windows

Test :

  • docker run hello-world
  • docker run -it ubuntu bash

FAQ :

  • If you must disable Hyper-V : dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
  • If you must enable Hyper-V : dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

Docker Commands : Docker Command Line

Node-Red Docker Installation in a first Container

Node-Red on Docker

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

This command will download the nodered/node-red-docker container from DockerHub and run an instance of it with the name of mynodered and with port 1880 exposed

Test :

Container Manipulations

  • Hit Ctrl-p Ctrl-q to detach from the container. This leaves it running in the background.
  • To reattach to the container: docker attach mynodered
  • To stop the container: docker stop mynodered
  • To start the container: docker start mynodered
  • To see the list of running containers : docker container ls

Tools to Manage easly Docker Containers : Kinematic

Mosquitto Installation in a second container

Various MQTT Broker are available like Mosquitto, RabbitMQ, EMQ, VerneMQ

See : Setting up a MQTT broker (Eclypse Mosquitto) using Docker

docker run --name mqtt --restart=always --net=host -tid -v /volume1/docker/mqtt/config:/mqtt/config:ro -v /volume1/docker/mqtt/log:/mqtt/log -v /volume1/docker/mqtt/data/:/mqtt/data/ toke/mosquitto
  • –name mqtt The name flag will allow us to easily identify which container is running MQTT. This is useful if we need to do some commands against the container (like starting, stopping etc) later.
  • –restart=always This is a powerful and handy flag to set. This will tell Docker to keep trying to re-start the MQTT Broker if it crashes, or on boot of the system. (This is one of the flags you can’t set when using the Synology Docker DSM Interface).
  • –net=host Another important and powerful flag. This gives your MQTT Broker full network access. This allows you to use 127.0.0.1 as the IP address of your MQTT Broker in Home Assistant, if you followed my setup guide. (This is one of the flags you can’t set when using the Synology Docker DSM Interface).
  • –itd This is actually three commands in the one. The important one is d. This tells Docker to run in detached mode. Once Docker runs the container, our SSH session is returned to us. If we don’t specify this, we’ll see the output from the MQTT Broker in our SSH console. Also import is the t, which tells Docker to tag the container for future use.
  • -v /volume1/docker/mqtt/config:/mqtt/config:ro Here we’re creating some mount volumes with the various -v flags. This will allow configuration to persist across reboots, as well as data. So, if your MQTT Broker goes down, any persistent messages you may have sent over the Broker should come back up. You can place it in any folder you like. Whatever you choose to use, the folder must exist before you will be able to start the MQTT Broker. If you want to use the same folder as I did above, you can create it by running mkdir -p /volume1/docker/mqtt/config
  • toke/mosquitto Finally this tells Docker which container to lookup on DockerHub. I’ve been using this image from Toke without issue for many months now.
Caveats : Docker Containers Mosquitto Configuration

Caveats : Docker Containers Network Configuration

Test with a GUI Clients

Test Shell MQTT Clients

docker run -it ubuntu bash

Test with Node-Red in a Docker Container

cours/iot/node-red_on_docker.1547634565.txt.gz · Dernière modification : 2019/01/16 10:29 de tigli