Docker Influxdb v1.8 entrypoint script

Hi folks,

did anyone have experience with launching Influx 1.8 with passing an entrypoint script creating the database?

docker run -d --restart unless-stopped --name myinflux -p 8086:8086 \
        -v influx-vol-data:/var/lib/influxdb \
        -v influx-vol-config:/etc/influxdb \
        -v influx-vol-scripts:/docker-entrypoint-initdb.d \
        arm32v7/influxdb -config /etc/influxdb/influxdb.conf /docker-entrypoint-initdb.d/init-influxdb.iql

where “init-influxdb.iql” contains “create database mydb;”

Everything seems fine, no errors but no database was created…

Hi @WagoGrim ,
Why do you need to create a database by passing a script ?
I’ve never try since when you use telegraf it creates the database by itself.

1 Like

Thanks. Its not really creating the database that is the problem but I used it for test. CoDeSys application can also create it… issue was originally the retention policy, this CoDeSys can not set (well maybe with cURL but not so nice solution). It is very convenient to script the database setup parameters that can not be set from .config-file or environment variables. And I read it should work.

Have you check the influxdb container logs ?

Yes, but it shows no information on creating the database or retention policy from the script… like it does if you do it manually etc. No errors. Strange.

Backup solution with cURL (e.g. WagoAppHTTP->FbHTTP_Client_Curl).
Creating retention policy:

Have you tried what is described in “Database Initialization” chapter? (I just found this)

docker run --rm \
      -e INFLUXDB_DB=db0 \
      -e INFLUXDB_ADMIN_USER=admin -e INFLUXDB_ADMIN_PASSWORD=supersecretpassword \
      -e INFLUXDB_USER=telegraf -e INFLUXDB_USER_PASSWORD=secretpassword \
      -v $PWD:/var/lib/influxdb \
      influxdb:1.8 /init-influxdb.sh

It looks you need to pass the db name and others parameters using environment variable.
No need to write your own script, but to apply the retention policy you might need it as well.

1 Like

It works now, thanks for the help so far. The problem may have been inconsistent testing or poor work from my side. If I now just remember to delete the data-volume each time testing the initial command works.

1 Like