I would like to deploy influxdb with docker compose and set it up without needing to use cli/web UI
Influxdb would not be accessable to anywhere else than the docker composes network (which would contain telegraf + some python)
Currently when I try to deploy the docker-compose I need to
- Start influx container
- Use the influxd cli to setup user + org
- Generate auth token
- restart the whole compose
I would like to be able to specify needed things with environment variables/configuration files but I have not found any help to it at influx 2.0 documentation. InfluxDB configuration options | InfluxDB OSS v2 Documentation specifies that
secret-store
Specifies the data store for secrets such as passwords and tokens. Store secrets in either the InfluxDB internal BoltDB or in Vault.
but I have not found a way to set the values.
Any help would be appreciated
scott
2
@juha-ylikoski The influx
CLI should be installed as part of the image, so you could script the token retrieval in your compose settings:
$(influx auth list --json | jq -r '.[].token')
There is a draft PR that includes a docker.compose file here. If you use this PR, be sure to update all the 9999
ports to 8086
.
Hi thanks for your reply. I was not able to find the pr you meant but I found Influx v2 - telegraf configuration on docker - #3 by Anaisdg which gave me idea to use separate container for influx-cli for setup
Container I added to my compose:
influxdb:
# From influxdb docs https://docs.influxdata.com/influxdb/v2.0/get-started/#download-and-run-influxdb-v2-0
image: influxdb:2.0.4
restart: unless-stopped
container_name: influxdb
networks:
- database
ports:
- "8086:8086"
volumes:
- ../influx/influxdb2:/var/lib/influxdb2
command: influxd run --reporting-disabled
influx-cli:
# initializes influxdb user/password/bucket...
image: influxdb:2.0.4
container_name: influx-cli
networks:
- database
depends_on:
- influxdb
command: sh -c 'sleep 5; influx setup --bucket "${INFLUX_DATA_BUCKET}" --token "${INFLUXDB_V2_TOKEN}" --org "${INFLUXDB_V2_ORG}" --username=${INFLUX_USERNAME} --password=${INFLUX_PASSWORD} --host=http://influxdb:8086 --force'
2 Likes