Skip to content

Setting Up Grafana with Docker Compose

Introduction to Grafana

Grafana is an open-source platform for monitoring and observability. It allows you to query, visualize, alert on, and understand your metrics no matter where they are stored.

Docker Compose Configuration for Grafana

This Docker Compose setup deploys Grafana in a Docker container, providing a powerful and flexible way to visualize and analyze your data.

Docker Compose File (docker-compose.yml)

version: "3.8"
services:
  grafana:
    image: grafana/grafana
    container_name: grafana
    restart: unless-stopped
    ports:
     - '3000:3000'
    volumes:
      - grafana-storage:/var/lib/grafana
volumes:
  grafana-storage: {}

Key Components of the Configuration

Service: Grafana

  • Image: grafana/grafana is the Docker image used for Grafana.
  • Ports:
  • 3000:3000 maps port 3000 on the host to port 3000 in the container, where Grafana's web interface is accessible.
  • Volumes:
  • grafana-storage:/var/lib/grafana provides persistent storage for Grafana's data.
  • Restart Policy: unless-stopped ensures that the Grafana service restarts automatically unless explicitly stopped.

Deploying Grafana

  1. Save the Docker Compose configuration in a docker-compose.yml file.
  2. Run docker compose up -d to start Grafana in detached mode.
  3. Access Grafana by navigating to http://<host-ip>:3000.

Default credentials

Grafana's default login is admin / admin. You will be prompted to change the password on first login.

Configuring and Using Grafana

After logging in:

  1. Go to Connections → Data Sources → Add data source
  2. Select Prometheus and set the URL to http://<prometheus-host-ip>:9090
  3. Click Save & Test to verify the connection
  4. Go to Dashboards → Import and enter a community dashboard ID (e.g. 1860 for the Node Exporter Full dashboard)

Updating Grafana

docker compose pull
docker compose up -d

Back up before updating

Your data lives in the grafana-storage named volume. Back this up before major version updates.

Youtube Video


If there is an issue with this guide or you wish to suggest changes, please raise an issue on GitHub.