Docker - InfluxDB 2.x Container Setup
InfluxDB is a time series database. In my case I store sensor data from Home Assistant in this database. But also price information from the stock exchange. And that works very well. InfluxDB also has its own reporting module, but you can also use Grafana for that (as I do).
An interesting alternative to InfluxDB is QuestDB. I’m experimenting with that too.
Here I describe my setup of the Docker InfluxDB container. I run this Docker container on a Ubuntu VM that runs via [[ Proxmox VE ]]. I perform the following on the CLI.
Docker pull command:
docker pull influxdb
Within my home folder I have created a Docker folder where I create a subfolder for each container:
cd ~
mkdir -p docker/influxdb
cd docker/influxdb
Also create folders where the InfluxDB data and config files can be stored:
mkdir data
mkdir config
I use the Nano text editor to create a shell script:
sudo nano influxdb_run.sh
With this shell script we are going to create the container.
Copy the following into influxdb_run.sh
:
IDu=$(id -u $(logname)) # Saves the logged in user id in the IDu variable
IDg=$(id -g $(logname)) # Saves the logged in user group in the IDg variable
docker run -d \
--name=influxdb \
--hostname=influxdb \
--ulimit nofile=32768:32768 \
-p 3004:8086 \
-v $PWD/data:/var/lib/influxdb2 \
-v $PWD/config:/etc/influxdb2 \
-v /etc/localtime:/etc/localtime:ro \
-e TZ=Europe/Amsterdam \
-e DOCKER_INFLUXDB_INIT_MODE=setup \
-e DOCKER_INFLUXDB_INIT_USERNAME=USER \
-e DOCKER_INFLUXDB_INIT_PASSWORD=PASS \
-e DOCKER_INFLUXDB_INIT_ORG=YOUR-ORG \
-e DOCKER_INFLUXDB_INIT_BUCKET=YOUR-BUCKET \
--restart unless-stopped \
influxdb:latest
If necessary, adjust the following:
–ulimit nofile=32768:32768
This setting is to preventtoo many open files
errors. You can get this error during bulk import of data (csv import or for example the batch node in Node-RED) in InfluxDB
-p 3004:8086
Choose a port that is still available, I chose3004
. Check this with netstat
-v $PWD/data:/var/lib/influxdb2
Choose the location for the Influxdb2 data. In this example it is the data map we created
-v $PWD/config:/etc/influxdb2
Choose the location for the Influxdb2 config. In this example it is the config map we created
-e TZ=Europe/Amsterdam
Pick the right timezone
-e DOCKER_INFLUXDB_INIT_USERNAME=USER
ReplaceUSER
with your own username
-e DOCKER_INFLUXDB_INIT_PASSWORD=PASS
ReplacePASS
with your own password
-e DOCKER_INFLUXDB_INIT_ORG=YOUR-ORG
ReplaceYOUR-ORG
with your own organization name - I used the name of the VM soUbuntuVM
-e DOCKER_INFLUXDB_INIT_BUCKET=YOUR-BUCKET
ReplaceYOUR-BUCKET
with your own bucket name - I use the name of the container, for examplehomeassistant
Exit Nano (CTRL-X) and save the changes.
Now create the container:
sudo sh influxdb_run.sh
Check if the container is running properly.
See also my notes about updating containers with Portainer or via the CLI. With Synology’s Docker Application, updating a container is also very easy.
Using InfluxDB
InfluxDB can now be accessed via the following URL:
http://<IP DOCKER HOST>:3004/
In addition to the Home Assistant bucket, I also use a bucket to store stock exchange data from an API. For testing I use ‘sandbox’ measurements. You can read here how to remove measurements with for example test data
Read other notes
Tags
Notes mentioning this note
- Docker - Home Assistant Container Setup with MariaDB and InfluxDB 2.x
Here I describe my setup of the Home Assistant container with MariaDB and InfluxDB 2.x.
- Home Assistant - Setup InfluxDB 2.x Database Size Sensor
Here I describe how to create a sensor for Home Assistant that will monitor the size of the InfluxDB 2.x...
- InfluxDB 2.x - Delete Measurement Using API or Docker Container Shell
I regularly delete a ‘sandbox’ measurement with test data. It is not very complicated to delete a measurement, but it...
- Docker - Grafana Container Setup
Here I describe my setup of the Docker Grafana container. With Grafana you can create beautiful dashboards.
- Node-RED - Access the InfluxDB API Using the HTTP Request Node
Within Node-RED you can use the InfluxDB nodes. But it is also possible to query the InfluxDB v2 API via...
- Docker - Telegraf Container Setup with InfluxDB to Monitor Docker
Here I describe my setup of the Docker Telegraf container. Telegraf from InfluxData is a server agent for collecting metrics...
- Docker - Telegraf Container with Syslog Receiver Input Plugin
I found out that an IoT device (smart power strip) had the setting to communicatie with a syslog server and...
- Docker - InfluxDB 2.x Container Setup
InfluxDB is a time series database.
- Docker - QuestDB Container Setup
QuestDB is a high-performance, open-source SQL database. QuestDB’s stack is engineered from scratch, zero-GC Java and dependency-free. It includes endpoints...
- Docker - Smartmeter2mqtt Container Setup with Webserver and Webrequest Output
Smartmeter2mqtt is an application that parses smartmeter data over the network or a P1 cable, I use it in combination...
- Docker - n8n Workflow Automation Container Setup
As a big fan of Node-RED and Apache Hop, it took me a long time to give n8n a try....
Comments
No comments found for this note.
Join the discussion for this note on this ticket. Comments appear on this page instantly.