Reputation: 53
I am working on a deployment of an influxdb for storing of real-time data. I have been using 1.8.4 for some time now and recently decided to update to v2.
My docker-compose.yml
file looks something like this:
influxdb:
image: influxdb:2.0.4-alpine
ports:
- "8086:8086"
volumes:
- ./influxdb/data:/var/lib/influxdb2
- ./influxdb/config:/etc/influxdb2
- ./influxdb/scripts:/docker-entrypoint-initdb.d
environment:
- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=${INFLUXDB_USR}
- DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUXDB_PWD}
- DOCKER_INFLUXDB_INIT_ORG=Org0
- DOCKER_INFLUXDB_INIT_BUCKET=bucket0
which indeed creates an initial bucket named bucket0
.
That said I would like to have a script in order to initialize further buckets, write some data or add auth. In my ./influxdb/scripts
directory I have a script init.sh
which would look like this:
#!/bin/bash
set -e
influx bucket create -n bucket1 -d "Bucket 1"
Then I would continue to use influx write
and influx auth
and all the nice stuff that influx cli provides, but the script above seems to not have any effect creating the bucket.
I have also tried to use the -c /etc/influxdb2/influx-configs
option or the --token
to no avail.
Doing a docker exec -it <container> /bin/bash
and then executing the exact same command created the bucket as expected.
Any ideas ? Thanks a lot !
Upvotes: 5
Views: 3968
Reputation: 36
I managed to run the following script at influxdb startup :
#!/bin/sh
set -e
influx bucket create -n first -r 7d
influx bucket create -n second -r 7d
Best regards
Upvotes: 2