Quick: Create an InfluxDB in Docker for Telegraf
Generate an configuration file
docker run –rm influxdb influxd config > influxdb.conf
Edit influxdb.conf to enable authentification
…
[http]
enabled = true
bind-address = « :8086 »
auth-enabled = true…
Create a docker volume
docker volume create influxdb-volume
Initialize the database (create a temporary container to initialize the database and store it in volume)
docker run –rm -e INFLUXDB_DB=telegraf -e INFLUXDB_HTTP_AUTH_ENABLED=true -e INFLUXDB_ADMIN_USER=admin -e INFLUXDB_ADMIN_PASSWORD=superpass -e INFLUXDB_USER=telegraf -e INFLUXDB_USER_PASSWORD=pass -v influxdb-volume:/var/lib/influxdb influxdb /init-influxdb.sh
Run the container
docker run –name=influxdb -d -p 8086:8086 -v $PWD/influxdb.conf:/etc/influxdb/influxdb.conf -v influxdb-volume:/var/lib/influxdb influxdb