InfluxDB in docker keep user after restart stack

I have a stack with Grafana, influxdb and telegraf. Works very nice! But if I restart my stack with docker-compose up -d, I have to recreate a user with privileges on the database. Can I make the user persistent? I have same problem with Grafana where datasource and dashboards are gone after relaunching the stack. But that is not were this forum is about :wink:

Which version of Influxdb telegraf and Grafana are you using? Please post your Docker-compose here so people can help you better. I was facing same issue actually but now I have handled everything. So provide details we can help you better.

1 Like

Thanks for reaction. My version is:
InfluxDB shell version: 1.8.4

I have created a simple yaml for test purposes:

    version: "2"
    services:
      influxdb:
        image: influxdb
        container_name: influxdb
        restart: always
        ports:
          - 8086:8086
        volumes:
          - influxdb-volume:/docker/dashboard
        environment:
          - INFLUXDB_DB=test
          - INFLUXDB_USER=test
          - INFLUXDB_ADMIN_ENABLED=true
          - INFLUXDB_ADMIN_USER=admintest
          - INFLUXDB_ADMIN_PASSWORD=passw
    volumes:
      influxdb-volume:
        external: false

I start the container with docker-compose up -d
Then I enter the container with docker exec -it influxdb bin/bash
Enter influx and create a user
Exit out of container and do docker-compose down.
If I start the ‘stack’ my user is gone??
I was expecting that the user I created would still be there @ restart of the container

@pjdw the mount-path you’ve configured for influxdb-volume doesn’t align with where the container stores its data/metadata. If you change the mount to influxdb-volume:/var/lib/influxdb I’d expect your data to persist across restarts.

Also to note: we have a PR open against DockerHub to update influxdb to 2.x. I’d recommend pinning your image to influxdb:1.8 unless you want to be auto-upgraded one day :grinning_face_with_smiling_eyes: