InfluxDB: Using Docker Compose for InfluxDB
InfluxDB is a "time series database developed by the company InfluxData. It is used for storage and retrieval of time series data in fields such as operations monitoring, application metrics, Internet of Things sensor data, and real-time analytics."
Besides installing InfluxDB on a server, or rent the service online, you can also use it locally on your Docker environment.
For me, the easiest is to use Docker Compose. Here's my docker-compose.yml
:
services:
influxdb2:
image: influxdb
hostname: influxdb
ports:
- 8086:8086
volumes:
- ./data:/var/lib/influxdb2
- ./config:/etc/influxdb2
We download the latest Docker image and start the container:
# docker compose pull
# docker compose up -d
[+] Pulling 11/11
✔ influxdb2 Pulled 54.1s
✔ 7ce705000c39 Pull complete 25.7s
✔ f0519160658a Pull complete 27.3s
✔ a7a8b4761500 Pull complete 27.9s
✔ 6470a1080b28 Pull complete 28.0s
✔ 41fcbe061689 Pull complete 28.2s
✔ f0e6484dfd2b Pull complete 44.8s
✔ e45f16829763 Pull complete 51.6s
✔ a0470c74fd97 Pull complete 51.7s
✔ d253f731479a Pull complete 51.7s
✔ ef753136aa92 Pull complete 51.8s
[+] Running 2/2
✔ Network influxdb_default Created 0.2s
✔ Container influxdb-influxdb2-1 Started 2.2s
After the start, we look at the log files:
# docker compose logs -f
influxdb2-1 | 2025-01-17T09:44:39.689394460Z warn boltdb not found at configured path, but DOCKER_INFLUXDB_INIT_MODE not specified, skipping setup wrapper {"system": "docker", "bolt_path": "/var/lib/influxdb2/influxd.bolt"}
influxdb2-1 | 2025-01-17T09:44:39.877623803Z warn boltdb not found at configured path, but DOCKER_INFLUXDB_INIT_MODE not specified, skipping setup wrapper {"system": "docker", "bolt_path": "/var/lib/influxdb2/influxd.bolt"}
influxdb2-1 | ts=2025-01-17T09:44:40.190605Z lvl=info msg="Welcome to InfluxDB" log_id=0u8vFc~W000 version=v2.7.11 commit=fbf5d4ab5e build_date=2024-12-02T17:48:08Z log_level=info
influxdb2-1 | ts=2025-01-17T09:44:40.190766Z lvl=warn msg="nats-port argument is deprecated and unused" log_id=0u8vFc~W000
influxdb2-1 | ts=2025-01-17T09:44:40.198795Z lvl=info msg="Resources opened" log_id=0u8vFc~W000 service=bolt path=/var/lib/influxdb2/influxd.bolt
influxdb2-1 | ts=2025-01-17T09:44:40.199113Z lvl=info msg="Resources opened" log_id=0u8vFc~W000 service=sqlite path=/var/lib/influxdb2/influxd.sqlite
influxdb2-1 | ts=2025-01-17T09:44:40.202901Z lvl=info msg="Bringing up metadata migrations" log_id=0u8vFc~W000 service="KV migrations" migration_count=20
influxdb2-1 | ts=2025-01-17T09:44:40.534790Z lvl=info msg="Bringing up metadata migrations" log_id=0u8vFc~W000 service="SQL migrations" migration_count=8
influxdb2-1 | ts=2025-01-17T09:44:40.636293Z lvl=info msg="Using data dir" log_id=0u8vFc~W000 service=storage-engine service=store path=/var/lib/influxdb2/engine/data
influxdb2-1 | ts=2025-01-17T09:44:40.636746Z lvl=info msg="Compaction settings" log_id=0u8vFc~W000 service=storage-engine service=store max_concurrent_compactions=2 throughput_bytes_per_second=50331648 throughput_bytes_per_second_burst=50331648
influxdb2-1 | ts=2025-01-17T09:44:40.636882Z lvl=info msg="Open store (start)" log_id=0u8vFc~W000 service=storage-engine service=store op_name=tsdb_open op_event=start
influxdb2-1 | ts=2025-01-17T09:44:40.637188Z lvl=info msg="Open store (end)" log_id=0u8vFc~W000 service=storage-engine service=store op_name=tsdb_open op_event=end op_elapsed=0.312ms
influxdb2-1 | ts=2025-01-17T09:44:40.637335Z lvl=info msg="Starting retention policy enforcement service" log_id=0u8vFc~W000 service=retention check_interval=30m
influxdb2-1 | ts=2025-01-17T09:44:40.637397Z lvl=info msg="Starting precreation service" log_id=0u8vFc~W000 service=shard-precreation check_interval=10m advance_period=30m
influxdb2-1 | ts=2025-01-17T09:44:40.646828Z lvl=info msg="Starting query controller" log_id=0u8vFc~W000 service=storage-reads concurrency_quota=1024 initial_memory_bytes_quota_per_query=9223372036854775807 memory_bytes_quota_per_query=9223372036854775807 max_memory_bytes=0 queue_size=1024
influxdb2-1 | ts=2025-01-17T09:44:40.658023Z lvl=info msg="Configuring InfluxQL statement executor (zeros indicate unlimited)." log_id=0u8vFc~W000 max_select_point=0 max_select_series=0 max_select_buckets=0
influxdb2-1 | ts=2025-01-17T09:44:40.683172Z lvl=info msg=Starting log_id=0u8vFc~W000 service=telemetry interval=8h
influxdb2-1 | ts=2025-01-17T09:44:40.684844Z lvl=info msg=Listening log_id=0u8vFc~W000 service=tcp-listener transport=http addr=:8086 port=8086
After that, we'll have to do a setup:
docker exec -ti influxdb-influxdb2-1 influx setup
> Welcome to InfluxDB 2.0!
? Please type your primary username <username>
? Please type your password <password>
? Please type your password again <password>
? Please type your primary organization name <organisation>
? Please type your primary bucket name <bucket>
? Please type your retention period in hours, or 0 for infinite <0>
? Setup with these parameters?
Username: influxadmin
Organization: private
Bucket: privatebucket
Retention Period: infinite
Yes
User Organization Bucket
influxadmin private privatebucket
Instead of that, we can also use the web interface to do that:
http://<hostname>:8086
In the web interface, we now can see that:
- Get Started
- Load Data
- Sources
- Buckets
- Telegraf
- Scrapers
- API Tokens
- Data Explorer
- Notebooks
- Dashboards
- Tasks
- Alerts and Alert History
- Settings
- Support
Now you can start to load your data. I'll show a simple but useful example in a later blog entry...