Skip to content

Docker M.I.N.G. stack

Marcin edited this page Mar 8, 2024 · 1 revision

M.I.N.G.

ming stack

Below is a step by step procedure of setting up Docker environment with M.I.N.G. stack, consisting of:

  • Mosquitto (already inbuild) - popular open source MQTT broker.
  • InfluxDB - open source time series database.
  • Node-RED - low-code development environment used to create flows of data and connect different data sources.
  • Grafana - open source visualisation platform.

Prerequisites

When deployed, containers inside Docker environment are automatically assigned to a default network, bridge. From there, an IP addresses are distributed on a 'first come first served' basis. This means that upon next start of docker environment, same container may be given a different IP address. That creates an issue for this stack, as communication between containers is required.
There are many ways of linking docker containers together to allow data exchange. In this example, a simple network creation will be used, to establish a new network cc100-stack, and add all new containers to it, with static IP addresses.

When connected to a controller using SSH Client, and with docker daemon running, run below command to add a new network to docker:

docker network create \
--driver=bridge \
--subnet=10.10.0.0/16 \
--ip-range=10.10.1.0/24 \
--gateway=10.10.1.254 \
-o "com.docker.network.bridge.host_binding_ipv4"="0.0.0.0" \
-o "com.docker.network.bridge.name"="cc100stack" \
-o "com.docker.network.bridge.mtu"="1500" \
-o "com.docker.network.bridge.enable_ip_masquerade"="true" \
-o "com.docker.network.bridge.icc"="true" \
cc100-stack

Please note, some of these parameters are optional - for more information please use this link

InfluxDB container

Installation

docker run -d \
-p 8086:8086 \
--network cc100-stack \
--ip 10.10.1.3 \
--restart=unless-stopped \
-e INFLUXDB_ADMIN_USER=admin \
-e INFLUXDB_ADMIN_PASSWORD=wago \
--name influxdb \
-v myInfluxVolume:/influxdb \
arm32v7/influxdb

A command below downloads InfluxDB latest image (if not present) and:
-d runs a controller in detached mode,
-p binds ports 8086 of controller and container
--network adds container to network 'cc100-stack'
--ip assigns static IP address '10.10.1.3'
--restart will allow container to automatically restart, unless user has stopped it,
-e allows to set up environment variables and in this case, these are username and password of InfluxDB admin account,
--name assigns a name for a container,
-v mounts a volume to a container.

For more information, please visit Docker Docs page | Docker container run

Node-RED container

Installation

docker run -d \
-p 1880:1880 \
--network cc100-stack \
--ip 10.10.1.1 \
--no-healthcheck \
--privileged=true \
-u root \
--restart=unless-stopped \
--name node-red \
-v node_red_user_data:/data 
nodered/node-red

A command below downloads Node-RED latest image (if not present) and:
-d runs a controller in detached mode,
-p binds ports 1880 of controller and container
--network adds container to network 'cc100-stack'
--ip assigns static IP address '10.10.1.1'
--no-healthcheck disables healthcheck logs on a container which slightly speeds up booting up process,
--privileged allows for full container capabilities (requires username with -u),
--restart will allow container to automatically restart, unless user has stopped it,
--name assigns a name for a container,
-v mounts a volume to a container.

For more information, please visit Docker Docs page | Docker container run

Grafana container

Installation

docker run -d \
--name grafana \
-p 3000:3000 \
--network cc100-stack \
--ip 10.10.1.2 \
--restart=unless-stopped \
--name grafana \
--privileged=true \
--user=root \
-v grafana-storage:/var/lib/grafana \
grafana/grafana

A command below downloads Grafana latest image (if not present) and:
-d runs a controller in detached mode,
-p binds ports 3000 of controller and container
--network adds container to network 'cc100-stack'
--ip assigns static IP address '10.10.1.2'
--privileged allows for full container capabilities (requires username with -u),
--restart will allow container to automatically restart, unless user has stopped it,
--name assigns a name for a container,
-v mounts a volume to a container.

For more information, please visit Docker Docs page | Docker container run