Skip to content

InfluxDB 3 in docker

docker-compose.yaml

yaml
name: influxdb3
services:
  influxdb3-core:
    container_name: influxdb3-core
    image: influxdb:3.4.2-core
    ports:
      - 8181:8181
    command:
      - influxdb3
      - serve
      - --node-id=node0
      - --object-store=file
      - --data-dir=/var/lib/influxdb3/data
      - --plugin-dir=/var/lib/influxdb3/plugins
    volumes:
      - type: bind
        source: ./influxdb3/core/data
        target: /var/lib/influxdb3/data
      - type: bind
        source: ./influxdb3/core/plugins
        target: /var/lib/influxdb3/plugins

创建admin token

bash
docker exec -it influxdb3-core influxdb3 create token --admin

输出:

bash
New token created successfully!

Token: apiv3_b1W9VsFD4LfgJdNZR5RG-NSl0Q9JW46rRhlEDD-ZpXX1SKktxwHhmtGVtUs9LtCvXxiKmlvZxXSGzeQDC8J_nA
HTTP Requests Header: Authorization: Bearer apiv3_b1W9VsFD4LfgJdNZR5RG-NSl0Q9JW46rRhlEDD-ZpXX1SKktxwHhmtGVtUs9LtCvXxiKmlvZxXSGzeQDC8J_nA

检查状态:

bash
curl -H "Authorization: Bearer apiv3_b1W9VsFD4LfgJdNZR5RG-NSl0Q9JW46rRhlEDD-ZpXX1SKktxwHhmtGVtUs9LtCvXxiKmlvZxXSGzeQDC8J_nA" http://localhost:8181/health

创建数据库:

bash
docker exec -it influxdb3-core influxdb3 create database --token apiv3_b1W9VsFD4LfgJdNZR5RG-NSl0Q9JW46rRhlEDD-ZpXX1SKktxwHhmtGVtUs9LtCvXxiKmlvZxXSGzeQDC8J_nA metrics

# Database "metrics" created successfully

查看所有数据库:

docker exec -it influxdb3-core influxdb3 show databases --token apiv3_b1W9VsFD4LfgJdNZR5RG-NSl0Q9JW46rRhlEDD-ZpXX1SKktxwHhmtGVtUs9LtCvXxiKmlvZxXSGzeQDC8J_nA