InfluxDB

Runs InfluxDB with an initial setup for admin user, organization, bucket, and token. This template is useful for storing metrics and time-series data from monitoring tools, scripts, or connected applications.

yaml

docker-compose.yml

services:
  influxdb:
    image: influxdb:2
    restart: unless-stopped
    ports:
      - ${INFLUXDB_HTTP_PORT}:8086
    environment:
      DOCKER_INFLUXDB_INIT_MODE: ${DOCKER_INFLUXDB_INIT_MODE}
      DOCKER_INFLUXDB_INIT_USERNAME: ${DOCKER_INFLUXDB_INIT_USERNAME}
      DOCKER_INFLUXDB_INIT_PASSWORD: ${DOCKER_INFLUXDB_INIT_PASSWORD}
      DOCKER_INFLUXDB_INIT_ORG: ${DOCKER_INFLUXDB_INIT_ORG}
      DOCKER_INFLUXDB_INIT_BUCKET: ${DOCKER_INFLUXDB_INIT_BUCKET}
      DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: ${DOCKER_INFLUXDB_INIT_ADMIN_TOKEN}
    volumes:
      - influxdb_data:/var/lib/influxdb2
      - influxdb_config:/etc/influxdb2
volumes:
  influxdb_data:
  influxdb_config:

.ENV

.env example

DOCKER_INFLUXDB_INIT_MODE=setup
DOCKER_INFLUXDB_INIT_USERNAME=admin
DOCKER_INFLUXDB_INIT_PASSWORD=change-me-now
DOCKER_INFLUXDB_INIT_ORG=docker-compose-hub
DOCKER_INFLUXDB_INIT_BUCKET=default
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=replace-me-token
INFLUXDB_HTTP_PORT=8086

deployment

Quick Start

  1. Create a working directory named after the service.
  2. Copy the compose file and generated `.env` into that directory.
  3. Review the variables and replace placeholders with real values.
  4. Run `docker compose up -d`.
mkdir influxdb
cd influxdb
# create docker-compose.yml
# create .env
docker compose up -d