【发布时间】:2023-03-27 00:33:01
【问题描述】:
我有一个在 docker-compose 中运行 Prometheus 的新服务器。 我希望能够重新加载配置文件(prometheus.yml),而不必停止和启动容器。
当然,因为我坚持将 promethues 存储在一个卷中,所以停止和启动并不是一个真正的问题,但它似乎有点过头了,特别是因为 prometheus 本身有一个非常方便的 api 来重新加载配置。
我看到其他人有类似的问题(例如here),但我无法让这些解决方案为我工作。也许我在那里忽略了一些东西。
docker-compose.yml
version: "3"
services:
grafana:
restart: always
container_name: grafana
image: grafana/grafana:6.2.1
ports:
- 3000:3000
volumes:
- grafanadata:/var/lib/grafana
prometheus:
restart: always
container_name: prometheus
image: prom/prometheus:v2.10.0
privileged: true
volumes:
- ./configuration/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheusdata:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--web.enable-admin-api'
- '--web.enable-lifecycle'
ports:
- 9090:9090
node:
restart: always
container_name: node
image: prom/node-exporter:v0.18.0
ports:
- 9100:9100
volumes:
grafanadata:
prometheusdata:
唉,我的结果..
当我运行 curl -X POST http://localhost:9090/-/reload 时,docker-compose 日志给出:
prometheus | level=info ts=2019-06-17T15:33:02.690Z caller=main.go:730 msg="Loading configuration file" filename=/etc/prometheus/prometheus.yml
prometheus | level=info ts=2019-06-17T15:33:02.691Z caller=main.go:758 msg="Completed loading of configuration file" filename=/etc/prometheus/prometheus.yml
所以普罗米修斯的结局很好。到目前为止一切都很好。
但是,当我编辑 ./configuration/prometheus/prometheus.yml 时,更改不会传播到容器。
此外,当我尝试在容器中编辑 /etc/promethus/prometheus.yml 时,我发现它是只读的(顺便说一句,容器没有“sudo”命令)。
是否有 docker 原生方式可以将这些配置文件热/实时重新加载到容器目录?
如前所述,down/start 选项目前有效,但我很好奇是否有更优雅的解决方案。
【问题讨论】:
标签: docker docker-compose prometheus