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


Service


version: '3'

services:

grafana:
build:
context: ./docker/grafana
hostname: grafana
ports:
- 3000:3000
volumes:
- ./var/docker/data/grafana:/var/lib/grafana:cached
environment:
GF_SECURITY_ADMIN_PASSWORD: grafana

Dockerfile


FROM grafana/grafana:5.1.0

COPY grafana.sh /grafana.sh

grafana.sh


This changes the password for "admin" user.


#!/bin/bash
set -e

grafana-cli admin reset-admin-password --homepath "/usr/share/grafana" ${GF_SECURITY_ADMIN_PASSWORD}