Hi!
I try to run InfluxDB in a container. Initially, I need to configure the database (Users, Databases, Retention policies etc.) when container starts.
InfluxDB docker documentation states:
Initialization Files
If the Docker image finds any files with the extensions .sh or .iql inside of the /docker-entrypoint-initdb.d folder, it will execute them. The order they are executed in is determined by the shell. This is usually alphabetical order.
I’ve created a simple script create_db.iql
which looks like this:
CREATE USER admin WITH PASSWORD password WITH ALL PRIVILEGES;
CREATE DATABASE metrics WITH DURATION 7d REPLICATION 1;
And added it in my Dockerfile
and built an image called influx
:
FROM influxdb:1.5.1
ADD influxdb.conf /etc/influxdb/
ADD create_db.iql /docker-entrypoint-initdb.d/
Then when I start my container from influx
image I get the following:
Creating influxdb ... done
Attaching to influxdb
influxdb | influxdb init process in progress...
influxdb | ts=2018-04-02T16:30:46.718202Z lvl=info msg="InfluxDB starting" log_id=07DnzykW000 version=1.5.1 branch=1.5 commit=cdae4ccde4c67c3390d8ae8a1a06bd3b4cdce5c5
influxdb | ts=2018-04-02T16:30:46.718267Z lvl=info msg="Go runtime" log_id=07DnzykW000 version=go1.9.2 maxprocs=2
influxdb | ts=2018-04-02T16:30:46.821429Z lvl=info msg="Using data dir" log_id=07DnzykW000 service=store path=/var/lib/influxdb/data
influxdb | ts=2018-04-02T16:30:46.821472Z lvl=info msg="Open store (start)" log_id=07DnzykW000 service=store trace_id=07Dnzz9G000 op_name=tsdb_open op_event=start
influxdb | ts=2018-04-02T16:30:46.821501Z lvl=info msg="Open store (end)" log_id=07DnzykW000 service=store trace_id=07Dnzz9G000 op_name=tsdb_open op_event=end op_elapsed=0.030ms
influxdb | ts=2018-04-02T16:30:46.821521Z lvl=info msg="Opened service" log_id=07DnzykW000 service=subscriber
influxdb | ts=2018-04-02T16:30:46.821526Z lvl=info msg="Starting monitor service" log_id=07DnzykW000 service=monitor
influxdb | ts=2018-04-02T16:30:46.821530Z lvl=info msg="Registered diagnostics client" log_id=07DnzykW000 service=monitor name=build
influxdb | ts=2018-04-02T16:30:46.821535Z lvl=info msg="Registered diagnostics client" log_id=07DnzykW000 service=monitor name=runtime
influxdb | ts=2018-04-02T16:30:46.821539Z lvl=info msg="Registered diagnostics client" log_id=07DnzykW000 service=monitor name=network
influxdb | ts=2018-04-02T16:30:46.821781Z lvl=info msg="Registered diagnostics client" log_id=07DnzykW000 service=monitor name=system
influxdb | ts=2018-04-02T16:30:46.821983Z lvl=info msg="Starting precreation service" log_id=07DnzykW000 service=shard-precreation check_interval=10m advance_period=30m
influxdb | ts=2018-04-02T16:30:46.821995Z lvl=info msg="Starting snapshot service" log_id=07DnzykW000 service=snapshot
influxdb | ts=2018-04-02T16:30:46.821999Z lvl=info msg="Starting continuous query service" log_id=07DnzykW000 service=continuous_querier
influxdb | ts=2018-04-02T16:30:46.822005Z lvl=info msg="Starting HTTP service" log_id=07DnzykW000 service=httpd authentication=true
influxdb | ts=2018-04-02T16:30:46.822025Z lvl=info msg="opened HTTP access log" log_id=07DnzykW000 service=httpd path=stderr
influxdb | ts=2018-04-02T16:30:46.822055Z lvl=info msg="Listening on HTTP" log_id=07DnzykW000 service=httpd addr=127.0.0.1:8086 https=false
influxdb | ts=2018-04-02T16:30:46.822051Z lvl=info msg="Storing statistics" log_id=07DnzykW000 service=monitor db_instance=_internal db_rp=monitor interval=10s
influxdb | ts=2018-04-02T16:30:46.822089Z lvl=info msg="Starting retention policy enforcement service" log_id=07DnzykW000 service=retention check_interval=30m
influxdb | ts=2018-04-02T16:30:46.822217Z lvl=info msg="Sending usage statistics to usage.influxdata.com" log_id=07DnzykW000
influxdb | ts=2018-04-02T16:30:46.822400Z lvl=info msg="Listening for signals" log_id=07DnzykW000
influxdb | [httpd] 127.0.0.1 - - [02/Apr/2018:16:30:47 +0000] "GET /ping HTTP/1.1" 204 0 "-" "InfluxDBShell/1.5.1" 32ec53f2-3693-11e8-8001-000000000000 95
influxdb | [httpd] 127.0.0.1 - - [02/Apr/2018:16:30:47 +0000] "POST /query?chunked=true&db=&epoch=ns&q=SHOW+DATABASES HTTP/1.1" 403 87 "-" "InfluxDBShell/1.5.1" 32ec6705-3693-11e8-8002-000000000000 157
influxdb | influxdb init process in progress...
influxdb | [httpd] 127.0.0.1 - - [02/Apr/2018:16:30:48 +0000] "GET /ping HTTP/1.1" 204 0 "-" "InfluxDBShell/1.5.1" 3385d058-3693-11e8-8003-000000000000 27
influxdb | [httpd] 127.0.0.1 - - [02/Apr/2018:16:30:48 +0000] "POST /query?chunked=true&db=&epoch=ns&q=SHOW+DATABASES HTTP/1.1" 403 87 "-" "InfluxDBShell/1.5.1" 3385e0e4-3693-11e8-8004-000000000000 55
influxdb | influxdb init process in progress...
influxdb | [httpd] 127.0.0.1 - - [02/Apr/2018:16:30:49 +0000] "GET /ping HTTP/1.1" 204 0 "-" "InfluxDBShell/1.5.1" 341f1cd6-3693-11e8-8005-000000000000 27
influxdb | [httpd] 127.0.0.1 - - [02/Apr/2018:16:30:49 +0000] "POST /query?chunked=true&db=&epoch=ns&q=SHOW+DATABASES HTTP/1.1" 403 87 "-" "InfluxDBShell/1.5.1" 341f2f19-3693-11e8-8006-000000000000 89
influxdb | influxdb init process in progress...
...
...
influxdb | [httpd] 127.0.0.1 - - [02/Apr/2018:16:38:19 +0000] "GET /ping HTTP/1.1" 204 0 "-" "InfluxDBShell/1.5.1" 403d2dbb-3694-11e8-803b-000000000000 26
influxdb | [httpd] 127.0.0.1 - - [02/Apr/2018:16:38:19 +0000] "POST /query?chunked=true&db=&epoch=ns&q=SHOW+DATABASES HTTP/1.1" 403 87 "-" "InfluxDBShell/1.5.1" 403d3cce-3694-11e8-803c-000000000000 62
influxdb | influxdb init process in progress...
influxdb | influxdb init process failed.
influxdb exited with code 1
InfluxDB can not overcome initialization stage.
There are 3 things looking weird to me:
- Sending usage statistics to usage.influxdata.com. What is this for? I don’t want that.
- The pair of GET + POST requests. Where did they came from? POST issues SHOW DATABASES command, but either no admin user was created yet, or it was created (definitely not by my script, since password is “admin” not “password”) so the request can not authenticate and receives 403 back. In any case, this is strange.
- Finally, “influxdb init process in progress…”, and “influxdb init process failed.” indicates that my simple script was not run successfully (and it wasn’t indeed). I do not know if that correlates with 1) and 2) but why is that happening?
Could you please tell me what am I doing wrong and how to fix this?