Grafana is an open-source dashboard and visualization platform that connects to dozens of data sources (Prometheus, Loki, Mimir, Tempo, PostgreSQL, and more) and renders metrics, logs, and traces in interactive panels. This guide deploys Grafana using Docker Compose with Traefik handling automatic HTTPS. By the end, you'll have Grafana running with a persistent data store and a secured admin login at your domain.
Set Up the Directory Structure
1. Create the project directory structure:
$ mkdir -p ~/grafana-monitoring/grafana-data
$ cd ~/grafana-monitoring
2. Set ownership for the Grafana data directory:
$ sudo chown -R 472:472 grafana-data
3. Create the environment file:
$ nano .env
DOMAIN=grafana.example.com
LETSENCRYPT_EMAIL=admin@example.com
GF_ADMIN_PASSWORD=changeme
Deploy with Docker Compose
1. Create the Docker Compose manifest:
$ nano docker-compose.yaml
services:
traefik:
image: traefik:v3.6
container_name: traefik
command:
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--entrypoints.web.http.redirections.entrypoint.to=websecure"
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
- "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
- "--certificatesresolvers.letsencrypt.acme.email=${LETSENCRYPT_EMAIL}"
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
volumes:
- "letsencrypt:/letsencrypt"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
restart: unless-stopped
grafana:
image: grafana/grafana:latest
container_name: grafana
hostname: grafana
expose:
- "3000"
volumes:
- "./grafana-data:/var/lib/grafana"
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GF_ADMIN_PASSWORD}
- GF_SERVER_ROOT_URL=https://${DOMAIN}
labels:
- "traefik.enable=true"
- "traefik.http.routers.grafana.rule=Host(`${DOMAIN}`)"
- "traefik.http.routers.grafana.entrypoints=websecure"
- "traefik.http.routers.grafana.tls.certresolver=letsencrypt"
- "traefik.http.services.grafana.loadbalancer.server.port=3000"
restart: unless-stopped
volumes:
letsencrypt:
2. Start the services:
$ docker compose up -d
3. Verify the services are running:
$ docker compose ps
4. View the logs:
$ docker compose logs
Access Grafana
Open https://grafana.example.com in a browser. Sign in with:
-
Username:
admin -
Password: the value of
GF_ADMIN_PASSWORDfrom.env
Navigate to Connections → Data sources to wire in Prometheus, Loki, or other backends.
Next Steps
Grafana is running and served securely over HTTPS. From here you can:
- Add Prometheus, Loki, Mimir, or Tempo as data sources
- Import community dashboards or build custom ones for your stack
- Configure alerting rules and notification channels
For the full guide with additional tips, visit the original article on Vultr Docs.
Top comments (0)