Grafana in Docker
Introduction
This guide will cover how to host a local Grafana instance as a Docker Container. This guide will use Portainer as a graphical front end for Docker, but the steps should remain relatively similar if using docker-compose or another graphical front end.
Prerequisites
Docker must be installed before proceeding. Portainer can optionally be installed.
OSS vs Enterprise
There are two versions: OSS (open source) and Enterprise. They are both free and have the same features. If you may want to get a license and pay for Grafana then use the Enterprise version as it can be unlocked without needing to reinstall. I will use the OSS version in this guide.
Stack File
Open up Portainer and create a new Stack file. I use "grafana" as the name for my stack file. Paste in the below docker-compose into the stack file:
services:
grafana:
image: grafana/grafana-oss
container_name: grafana
ports:
- "3000:3000"
volumes:
- grafana-data:/var/lib/grafana
restart: unless-stopped
volumes:
grafana-data:
Change Ports
If you want to change the ports, update the ports
section. The left value is what is exposed to your operating system. So to use port "9999" it can be updated to
ports:
- '9999:3000'
Sign In
Open Web Browser
By default Grafana should be running on http://localhost:3000. If you installed Grafana on a different host than what you use to connect to it, replace "localhost" with the internal IP address of the host where Grafana was installed.
Credentials
The username and password is admin
.
When prompted, change the password to something more secure.
Once you have signed in you can begin adding data sources and creating dashboards.