Portainer Templates logo

Portainer Templates

Grafana Dashboard Grafana Dashboard

edge

Multi-platform open-source interactive visualization web application

Image details

Pulls: 5.3B
Architectures: amd64, arm64, arm/v7
Image size: 198 MB
Latest: 11.6.16-ubuntu
User: grafana
Created: Feb 06, 2015
Updated: 16 hours ago
Status: active

Source details

Stars: 75.7k
Forks: 14.3k
Language: TypeScript
License: AGPL-3.0
Updated: 2 minutes ago
Website: grafana.com/

Configuration

Type
Compose
Platform
linux
Image
grafana/grafana
Ports
3000:3000
Volumes
/var/lib/grafana : grafana_data
Env vars
GF_SECURITY_ADMIN_USER=${grafana_admin}GF_SECURITY_ADMIN_PASSWORD=${grafana_password}GF_INSTALL_PLUGINS=
Restart
unless-stopped
Source

Template by portainer·Source

Installation

  1. Ensure both Docker and Portainer are installed, and up-to-date
  2. Log into your Portainer web UI
  3. Under Settings → App Templates, paste the below URL
  4. Head to Home → App Templates, and the list of apps will show up
  5. Select the app you wish to deploy, fill in any config options, and hit Deploy

Template Import URL

https://raw.githubusercontent.com/Lissy93/portainer-templates/main/templates.json
Show Me demo

docker run -d --name grafana \
  -p 3000:3000 \
  -e 'GF_SECURITY_ADMIN_USER=${grafana_admin}' \
  -e 'GF_SECURITY_ADMIN_PASSWORD=${grafana_password}' \
  -e 'GF_INSTALL_PLUGINS=' \
  -v grafana_data:/var/lib/grafana \
  --restart=unless-stopped \
  grafana/grafana

If the stack expects env vars, set them or add them to a .env file first.

version: '3.6'
services:
   grafana:
    image: grafana/grafana
    container_name: grafana
    restart: unless-stopped
    networks:
      - monitoring
    environment:
      - GF_SECURITY_ADMIN_USER=${grafana_admin}
      - GF_SECURITY_ADMIN_PASSWORD=${grafana_password}  #change the password
      - GF_INSTALL_PLUGINS=
    ports:
      - '3000:3000'
    volumes:
      - grafana_data:/var/lib/grafana
      
networks:
  monitoring:
 
volumes:
  grafana_data:

Or, use the original compose file, straight from the template repo. Deploy with:

git clone https://github.com/portainer/templates
cd templates
docker compose -f edge/grafana/docker-compose.yml up -d

Save this file as grafana-dashboard-stack.yml, then from a manager node, run docker stack deploy -c grafana-dashboard-stack.yml grafana-dashboard

version: '3.8'
services:
  grafana-dashboard:
    image: grafana/grafana
    ports:
      - '3000:3000'
    volumes:
      - grafana_data:/var/lib/grafana
    environment:
      GF_SECURITY_ADMIN_USER: ${grafana_admin}
      GF_SECURITY_ADMIN_PASSWORD: ${grafana_password}
      GF_INSTALL_PLUGINS: ''
    deploy:
      restart_policy:
        condition: any

Save each file below into a folder, then run kubectl apply -f .
Written for k3s, but works on any cluster: bind mounts use hostPath, named volumes get a persistent volume claim, and ports are exposed via a LoadBalancer service.

grafana-dashboard-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: grafana-dashboard
  labels:
    app: grafana-dashboard
spec:
  replicas: 1
  selector:
    matchLabels:
      app: grafana-dashboard
  template:
    metadata:
      labels:
        app: grafana-dashboard
    spec:
      containers:
        - name: grafana-dashboard
          image: grafana/grafana
          env:
            - name: GF_SECURITY_ADMIN_USER
              value: ${grafana_admin}
            - name: GF_SECURITY_ADMIN_PASSWORD
              value: ${grafana_password}
            - name: GF_INSTALL_PLUGINS
              value: ''
          ports:
            - containerPort: 3000
              protocol: TCP
          volumeMounts:
            - name: grafana-dashboard-data-0
              mountPath: /var/lib/grafana
      volumes:
        - name: grafana-dashboard-data-0
          hostPath:
            path: grafana_data

grafana-dashboard-service.yaml

apiVersion: v1
kind: Service
metadata:
  name: grafana-dashboard
spec:
  type: LoadBalancer
  selector:
    app: grafana-dashboard
  ports:
    - name: 3000-tcp
      port: 3000
      targetPort: 3000
      protocol: TCP

Save this file as ~/.config/containers/systemd/grafana-dashboard.container

[Unit]
Description=Grafana Dashboard

[Container]
Image=grafana/grafana
ContainerName=grafana-dashboard
PublishPort=3000:3000
Environment=GF_SECURITY_ADMIN_USER=${grafana_admin}
Environment=GF_SECURITY_ADMIN_PASSWORD=${grafana_password}
Environment=GF_INSTALL_PLUGINS=
Volume=grafana_data:/var/lib/grafana

[Service]
Restart=always

[Install]
WantedBy=default.target

Then reload systemd and start the service:

systemctl --user daemon-reload
systemctl --user start grafana-dashboard

For a system-wide service, use /etc/containers/systemd/ and drop --user.

For more installation options, see the Documentation in our GitHub repo

For app-specific guidance, check Grafana Dashboard's own repo at grafana/grafana

Grafana Docker image

Run the Grafana Docker container

Start the Docker container by binding Grafana to external port 3000.
docker run -d --name=grafana -p 3000:3000 grafana/grafana

Try it out, default admin user credentials are admin/admin.
Further documentation on how to run Docker can be found at http://docs.grafana.org/installation/docker/.

Changelog

You can find information about Grafana in our docs, or find out what's new in the latest release here!

Serve Grafana Dashboard on your own domain behind Caddy, Nginx or Traefik. Fill in your domain and copy the result. It's a starting point, some apps need their own base URL or extra headers set too.

Proxying grafana-dashboard.example.com to http://grafana:3000

Add this to your Caddyfile

grafana-dashboard.example.com {
	reverse_proxy http://grafana:3000
}

Check the logs first

Nine times out of ten the logs tell you exactly what went wrong.

  • In Portainer, go to Containers, click the container, then Logs. Or run docker logs <container>
  • Exit codes help too: 137 means killed, usually out of memory. 126 or 127 means the command inside the image is broken.

Port already in use

If deployment fails with "Bind for 0.0.0.0:3000 failed: port is already allocated", something else on your server is using that port.

  • Find what's using it: sudo ss -tlnp | grep :3000
  • Stop the other service, or pick a different host port. In 3000:3000 only the left number is yours to change, the right one belongs to the app.

Running but the page won't load

The container is up but nothing appears in your browser.

  • Use your server's real IP: http://your-server-ip:3000. The 0.0.0.0 link Portainer shows isn't a real address.
  • Give it a minute after first deploy, grafana can take a while to initialise.
  • Make sure your firewall allows the port, e.g. sudo ufw allow 3000

Image won't pull

Test the pull directly on the host: docker pull grafana/grafana

  • "manifest unknown" means the tag no longer exists. This template uses latest, so try pinning a specific version instead.
  • "toomanyrequests" is the Docker Hub rate limit. Log in with docker login to raise it.
  • "no space left on device" means a full disk. Reclaim space with docker system prune

"exec format error"

This means the image was built for a different CPU architecture than your server.

  • This image supports: amd64, arm64, arm/v7
  • Check yours with uname -m: x86_64 is amd64, aarch64 is arm64. Raspberry Pi and other ARM boards are the usual culprits.

Container keeps restarting

The unless-stopped restart policy relaunches the app after every crash, so the real error can scroll past.

  • Check the logs right after a restart, the last few lines before it died are the useful ones.
  • Get the exit code with docker inspect <container> --format '{{.State.ExitCode}}'
  • Still stuck? Redeploy once with the restart policy set to no so the failure stays visible.

Required settings are blank

GF_INSTALL_PLUGINS has no default value, and grafana may crash or misbehave if left empty.

  • Fill it in on the deploy screen before hitting deploy.

Stack won't deploy

Compose stacks fail fast on small mistakes, and Portainer shows the reason just above the editor.

  • YAML only accepts spaces for indentation, a single tab breaks the whole file.

Raise an issue

Found something which isn't working as it should? Here's how to report it.

Similar apps