gol*_*pha 8 docker docker-compose prometheus
我有一个在 docker-compose 中运行 Prometheus 的新服务器。我希望能够重新加载配置文件(prometheus.yml)而不必停止和启动容器。
当然,因为我将 prometheus 的存储持久化在一个卷中,所以停止和启动并不是真正的问题,但它似乎有点矫枉过正,尤其是因为 prometheus 本身有一个如此方便的 api 来重新加载配置。
我看到其他人有类似的问题(例如在这里),但我一直无法让这些解决方案对我有用。也许我在俯瞰那里的东西。
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:
Run Code Online (Sandbox Code Playgroud)
唉,我的结果..
当我运行curl -X POST http://localhost:9090/-/reloaddocker-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
Run Code Online (Sandbox Code Playgroud)
所以普罗米修斯的结局工作正常......到目前为止一切都很好。
但是,当我编辑./configuration/prometheus/prometheus.yml更改时,不会传播到容器。此外,当我尝试/etc/promethus/prometheus.yml在容器中进行编辑时,我看到它是只读的(顺便说一句,容器没有“sudo”命令)。
是否有 docker 本地方式将这些配置文件热/实时重新加载到容器目录?
如前所述,关闭/启动选项现在有效,但我很好奇是否有更优雅的解决方案。
您的问题可能是,您的编辑器没有将更改后的文件保存在同一索引节点下。因此 dockerd 没有意识到文件已更改,因为它写入了新的 inode。解决方案可能是挂载完整目录或告诉编辑器不要使用临时文件:
即对于 Sublime,将 "atomic_save": false 设置为用户首选项可能会有所帮助(结果不清楚),或者对于 vim,请参阅https://github.com/moby/moby/issues/15793#issuecomment-571932545
一般来说,这个问题对于这个主题来说非常有趣:https://github.com/moby/moby/issues/15793
| 归档时间: |
|
| 查看次数: |
9301 次 |
| 最近记录: |