Skip to main content

Docker Installation

This guide covers installing and running Grafana using Docker containers. You can run Grafana using the Docker CLI or Docker Compose.

Docker Images

Grafana provides official Docker images hosted on Docker Hub:
  • Grafana Enterprise: grafana/grafana-enterprise
  • Grafana Open Source: grafana/grafana
Starting with Grafana 12.4.0, the grafana/grafana-oss repository will no longer be updated. Use grafana/grafana instead, which contains the same Grafana OSS images.
The default images are built on Alpine Linux 3.23.3. All images run on port 3000 by default and use UID 472 for the grafana user.

Run Grafana with Docker CLI

The simplest way to run Grafana is using the Docker CLI.
1
Run Grafana container
2
Run the latest stable version of Grafana Enterprise:
3
docker run -d -p 3000:3000 --name=grafana grafana/grafana-enterprise
4
This command:
5
  • Runs the container in detached mode (-d)
  • Publishes port 3000 to the host (-p 3000:3000)
  • Names the container grafana (--name=grafana)
  • Uses the latest Enterprise image
  • 6
    Access Grafana
    7
    Open your browser and navigate to http://localhost:3000. Sign in with:
    8
  • Username: admin
  • Password: admin
  • 9
    You’ll be prompted to change the password on first login.
    10
    Stop the container
    11
    To stop the Grafana container:
    12
    docker stop grafana
    

    Persistent Storage

    By default, Grafana data is stored inside the container and will be lost when the container is removed. Use Docker volumes or bind mounts to persist data. Docker volumes are managed by Docker and are the recommended approach for persistent storage.
    1
    Create a volume
    2
    docker volume create grafana-storage
    
    3
    Verify the volume
    4
    docker volume inspect grafana-storage
    
    5
    Run Grafana with the volume
    6
    docker run -d -p 3000:3000 --name=grafana \
      --volume grafana-storage:/var/lib/grafana \
      grafana/grafana-enterprise
    

    Using Bind Mounts

    Bind mounts map a host directory to the container. You must run the container with a user that has permission to access the directory.
    1
    Create a data directory
    2
    mkdir data
    
    3
    Run Grafana with bind mount
    4
    docker run -d -p 3000:3000 --name=grafana \
      --user "$(id -u)" \
      --volume "$PWD/data:/var/lib/grafana" \
      grafana/grafana-enterprise
    

    Environment Variables

    Configure Grafana using environment variables. All Grafana configuration options can be set using the GF_<SectionName>_<KeyName> format.

    Common Configuration

    docker run -d -p 3000:3000 --name=grafana \
      -e "GF_LOG_LEVEL=debug" \
      -e "GF_SERVER_ROOT_URL=http://my.grafana.server/" \
      -e "GF_SECURITY_ADMIN_PASSWORD=secure_password" \
      grafana/grafana-enterprise
    

    Environment Variables for Docker Secrets

    You can use Docker secrets by appending __FILE to environment variables:
    docker run -d -p 3000:3000 --name=grafana \
      -e "GF_SECURITY_ADMIN_PASSWORD__FILE=/run/secrets/admin_password" \
      grafana/grafana-enterprise
    

    Install Plugins

    Install plugins at container startup using the GF_PLUGINS_PREINSTALL environment variable.

    Install from plugin catalog

    docker run -d -p 3000:3000 --name=grafana \
      -e "GF_PLUGINS_PREINSTALL=grafana-clock-panel,grafana-simple-json-datasource" \
      grafana/grafana-enterprise
    

    Install specific version

    docker run -d -p 3000:3000 --name=grafana \
      -e "[email protected]" \
      grafana/grafana-enterprise
    

    Install from custom URL

    docker run -d -p 3000:3000 --name=grafana \
      -e "GF_PLUGINS_PREINSTALL=custom-plugin@@https://example.com/plugin.zip" \
      grafana/grafana-enterprise
    

    Run Grafana with Docker Compose

    Docker Compose simplifies multi-container deployments using YAML configuration files.

    Basic Configuration

    Create a docker-compose.yaml file:
    services:
      grafana:
        image: grafana/grafana-enterprise
        container_name: grafana
        restart: unless-stopped
        ports:
          - '3000:3000'
    
    Start Grafana:
    docker compose up -d
    
    Stop Grafana:
    docker compose down
    

    With Persistent Storage

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

    With Environment Variables

    services:
      grafana:
        image: grafana/grafana-enterprise
        container_name: grafana
        restart: unless-stopped
        environment:
          - GF_SERVER_ROOT_URL=http://my.grafana.server/
          - GF_PLUGINS_PREINSTALL=grafana-clock-panel
          - GF_LOG_LEVEL=info
        ports:
          - '3000:3000'
        volumes:
          - grafana-storage:/var/lib/grafana
    
    volumes:
      grafana-storage: {}
    

    With Bind Mounts

    services:
      grafana:
        image: grafana/grafana-enterprise
        container_name: grafana
        restart: unless-stopped
        user: '0'
        ports:
          - '3000:3000'
        volumes:
          - '$PWD/data:/var/lib/grafana'
    

    Container Configuration Paths

    The Grafana Docker image uses the following paths:
    PathDescription
    /etc/grafana/grafana.iniConfiguration file
    /var/lib/grafanaData directory (dashboards, users, etc.)
    /var/log/grafanaLog directory
    /usr/share/grafanaInstallation directory
    /var/lib/grafana/pluginsPlugins directory
    /etc/grafana/provisioningProvisioning directory

    Entry Point Script

    The Docker image uses /run.sh as the entry point, which:
    1. Validates file permissions for configuration and data directories
    2. Processes environment variables ending in __FILE for Docker secrets
    3. Configures AWS credentials if GF_AWS_PROFILES is set
    4. Starts the Grafana server with appropriate configuration flags

    Next Steps

    • Configure Grafana data sources
    • Set up authentication
    • Install additional plugins
    • Configure provisioning for dashboards and data sources

    Build docs developers (and LLMs) love