Hello everyone!

We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.

Use example below to setup InfluxDB docker container. You can then access to GUI from your browser via http://{network-gateway-ip or container-ip}:8086 with influxdb:influxdb.


Service


version: '3'

services:

influxdb:
build:
context: ./docker/influxdb
hostname: influxdb
ports:
- 8086:8086
volumes:
- ./var/docker/data/influxdb:/var/lib/influxdb:cached
environment:
INFLUXDB_USER: influxdb
INFLUXDB_USER_PASSWORD: influxdb

Dockerfile


FROM influxdb:1.5.3

COPY influxdb.sh /docker-entrypoint-initdb.d/influxdb.sh

influxdb.sh


Creates a user without creating a database.


#!/bin/bash
set -e

influx -execute "CREATE USER ${INFLUXDB_USER} WITH PASSWORD '${INFLUXDB_USER_PASSWORD}' WITH ALL PRIVILEGES"

cat >> /etc/influxdb/influxdb.conf <[http]
auth-enabled = true
EOD