version: '3.7'

services:
  telegraf:
    image: telegraf
    container_name: telegraf
    restart: always
    volumes:
      - ./telegraf:/etc/telegraf
      - /sys:/rootfs/sys:ro
      - /proc:/rootfs/proc:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      - 'HOST_PROC=/rootfs/proc'
      - 'HOST_SYS=/rootfs/sys'
      - /etc/localtime:/etc/localtime:ro
    networks:
      - monitor
    depends_on:
      - influxdb

  influxdb:
    # image: influxdb:2.0
    image: influxdb:1.8
    container_name: influxdb
    restart: always
    environment:
      # - DOCKER_INFLUXDB_INIT_MODE=setup
      # - DOCKER_INFLUXDB_INIT_USERNAME=my-user
      # - DOCKER_INFLUXDB_INIT_PASSWORD=my-password
      # - DOCKER_INFLUXDB_INIT_ORG=my-org
      # - DOCKER_INFLUXDB_INIT_BUCKET=my-bucket

      # - INFLUXDB_DB=db0
      - INFLUXDB_HTTP_AUTH_ENABLED=true
      - INFLUXDB_ADMIN_USER=telegraf
      - INFLUXDB_ADMIN_PASSWORD=telegraf
      # - PRE_CREATE_DB=telegraf
      # - ADMIN_USER="telegraf"
      # - INFLUXDB_INIT_PWD="telegraf"
      # - GOGC=10
      # - INFLUXDB_DATA_INDEX_VERSION=tsi1
    ports:
      - "8086:8086"
    expose:
      - "8090"
      - "8099"
    volumes:
      # - "./influxdb/data:/var/lib/influxdb2"
      # - "./influxdb/config:/etc/influxdb2"
      - "./influxdb/db:/var/lib/influxdb"
    networks:
      - monitor

networks:
  monitor:
    name: 'influxdb-net'

