Setting up Docker, Mosquitto, NodeRed, Grafana, Influxdb

This post will show you how to setup docker, docker-compose, Mosquitto, NodeRed, Grafana, and InfluxDB to receive and process MQTT messages sent from a ESP32 sensor.

Docker

I will be using a Virtual Machine (Ubuntu 20.04 LTS server) to setup docker and docker compose. From there we will install everything we need at once by running docker-compose up -d. ttncat on Github had a great workshop that outlined exactly how to do this. The biggest difference between this tutorial and ttncat’s is that I updated the node-red docker image to use the latest LTS version.

Source code for this project is here.

On a new Ubuntu 20.04 install I ran the following commands to get everything updated and docker installed:

sudo apt update
sudo apt upgrade -y
sudo apt install -y htop vim net-tools tmux apt-transport-https ca-certificates curl gnupg-agent software-properties-common build-essential

# install docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
	   $(lsb_release -cs) \
	      stable"
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
sudo usermod -aG docker $USER

Then I installed docker-compose by following the current tutorial. The actual version number may be different when you do this install.

# Install Docker Compose https://docs.docker.com/compose/install/
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

I followed up by installing the influxdb client (which will be the last package we need to update for this tutorial):

# Tool for connecting to influxdb
sudo apt install influxdb-client

After rebooting the machine it should be ready to run docker-compose.

Installing Mosquitto, NodeRed, Grafana, and InfluxDB

The docker-compose.yml file explains how to install and configure each of these applications. Default username and passwords are in the docker-compose file, so be sure to change those to meet your security requirements. I do not recommend exposing these services externally.

I copied the folder for this project into a docker folder on the VM, so to install everything run:

docker-compose up -d

You can check the status:

docker container ls

in my case I see that all of the servers are running:

The next post will verify that each of these services works.

Need Help or some software changes?

With services like TeamViewer I can jump onto your computer and help you out for a reasonable price. Send me a message below and I’ll get back to you ASAP.