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