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"
    image: grafana/grafana
    container_name: grafana
    restart: unless-stopped
     - '3000:3000'
      - grafana-storage:/var/lib/grafana
  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.

Configuring and Using Grafana

After deployment, configure Grafana through its web interface to connect to your data sources, create dashboards, and set up alerts.

Youtube Video