Grafana
This example shows a small, practical Docker Compose setup for Grafana, the open-source analytics and dashboarding platform.
The stack includes:
- A single Grafana container
- Persistent storage via a Docker volume
- Local-only port binding for security
- Simple reverse-proxy instructions (Caddy example)
1. docker-compose.yml
Create a folder and add:
services:
grafana:
image: grafana/grafana:latest
restart: always
ports:
- "127.0.0.1:3000:3000"
environment:
- GF_SERVER_DOMAIN=grafana.example.com
- GF_SERVER_ROOT_URL=https://grafana.example.com
volumes:
- grafana_data:/var/lib/grafana
volumes:
grafana_data:
Start the stack:
docker compose up -d
Grafana will be available locally at:
http://localhost:3000
Default login:
Username: admin
Password: admin
You will be prompted to change the password on first login.
2. Add a Reverse Proxy (Caddy example)
To expose Grafana with HTTPS, use a simple Caddyfile:
grafana.example.com {
reverse_proxy localhost:3000
}
Reload Caddy:
systemctl reload caddy
Caddy will automatically request and renew the TLS certificate.
3. Optional: Auto-Start with systemd
# /etc/systemd/system/grafana.service
[Unit]
Description=Grafana (Docker Compose)
After=network.target
[Service]
Type=oneshot
WorkingDirectory=/root/grafana
ExecStart=/usr/bin/docker compose up -d
ExecStop=/usr/bin/docker compose down
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Enable the service:
systemctl enable grafana
systemctl start grafana
4. Deploy on Hostim.dev Instead
If you don’t want to manage servers, proxies, or systemd:
- Create a project on Hostim.dev
- Choose Paste Docker Compose
- Insert the YAML from this example
Hostim.dev automatically configures HTTPS, domains, restarts, logs, and persistent storage.