data "docker_registry_image" "prometheus" { name = "prom/prometheus:v2.53.2" } resource "docker_image" "prometheus" { name = data.docker_registry_image.prometheus.name pull_triggers = [data.docker_registry_image.prometheus.sha256_digest] } resource "docker_volume" "prometheus" { name = "prometheus" } resource "docker_container" "prometheus" { image = docker_image.prometheus.image_id name = "prometheus" must_run = true env = [ ] command = [ #"/bin/prometheus", "--config.file=/etc/prometheus/prometheus.yml", "--storage.tsdb.path=/prometheus", "--web.console.libraries=/usr/share/prometheus/console_libraries", "--web.console.templates=/usr/share/prometheus/consoles", "--storage.tsdb.retention.time=100y", ] networks_advanced { name = data.docker_network.dn42.name } # networks_advanced { # name = data.docker_network.traefik.name # } # dynamic "labels" { # for_each = [ # { label = "traefik.enable", value = "true" }, # { label = "traefik.docker.network", value = data.docker_network.traefik.name }, # { label = "traefik.http.routers.prometheus.rule", value = "Host(`prometheus.trygvis.io`)" }, # { label = "traefik.http.routers.prometheus.entrypoints", value = "websecure" }, # { label = "traefik.http.routers.prometheus.tls.certresolver", value = "linode" }, # ] # content { # label = labels.value["label"] # value = labels.value["value"] # } # } mounts { source = local.path target = "/etc/prometheus" type = "bind" read_only = false } volumes { volume_name = docker_volume.prometheus.name read_only = false container_path = "/prometheus" } } locals { path = "/etc/docker-service/prometheus" }