version: "3.8" services: prometheus: image: prom/prometheus:latest container_name: prometheus volumes: - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro - prometheus_data:/prometheus command: - "--config.file=/etc/prometheus/prometheus.yml" - "--storage.tsdb.path=/prometheus" - "--storage.tsdb.retention.time=15d" - "--web.enable-lifecycle" ports: - "9090:9090" networks: - monitoring restart: unless-stopped grafana: image: grafana/grafana-oss:latest container_name: grafana environment: - GF_SECURITY_ADMIN_USER=admin - GF_SECURITY_ADMIN_PASSWORD=admin # optional but handy - GF_SERVER_DOMAIN=localhost - GF_SERVER_ROOT_URL=%(protocol)s://%(domain)s:%(http_port)s/ volumes: - grafana_data:/var/lib/grafana ports: - "3000:3000" networks: - monitoring depends_on: - prometheus restart: unless-stopped networks: monitoring: volumes: prometheus_data: grafana_data: