Search code examples
dockerinfluxdb

Launching a InfluxDB container in docker with a default database name


I'm running the following command to launch a InfluxDB container. This should create a new databse with the name defaultdb.

docker run -p 8086:8086 \
      -e INFLUXDB_DB=defaultdb -e INFLUXDB_ADMIN_ENABLED=true \
      -e INFLUXDB_ADMIN_USER=admin -e INFLUXDB_ADMIN_PASSWORD=adminpass \
      -e INFLUXDB_USER=user -e INFLUXDB_USER_PASSWORD=userpass \
      -v influxdb:/var/lib/influxdb \
      influxdb:latest 

But it doesnt create the default databse defaultdb. It creates the databse db0 instead of defaultdb. What I'm doing wrong?

https://hub.docker.com/_/influxdb/

Thanks in advance.


Solution

  • The issue was due to the INFLUXDB_ADMIN_ENABLED=true line.

    The documentation states:

    The administrator interface is deprecated as of 1.1.0 and will be removed in 1.3.0.

    I was using the latest version which is (currently) the 1.4 so it seems that there was a problem with that deprecated INFLUXDB_ADMIN_ENABLED variable.

    Removing that line, everything worked perfectly.

    docker run -p 8086:8086 \
          -e INFLUXDB_DB=defaultdb \
          -e INFLUXDB_ADMIN_USER=admin \
          -e INFLUXDB_ADMIN_PASSWORD=adminpass \
          -e INFLUXDB_USER=user \
          -e INFLUXDB_USER_PASSWORD=userpass \
          -v influxdb:/var/lib/influxdb \
          influxdb:latest