首页 > 解决方案 > Docker + Windows + Prometheus:如何/在哪里提供配置文件

问题描述

我正在尝试传入我自己的 prometheus.yml 文件。我是 docker 新手,我找到的示例都在 Linux 系统上,而且我在 Windows 上。如何/在哪里提供我自己的 yaml 文件的最佳方式?以下命令无法启动 docker 容器。

docker run -d -p 9090:9090 -v c:\Docker\prometheus.yml:/etc/prometheus/prometheus.yml --name=prometheus prom/prometheus -config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -storage.local.memory-chunks=10000

当我尝试运行此命令时,Docker 会提示我是否要共享我的 C: 驱动器,但我仍然无法让容器运行。

这是码头工人日志所说的:

Error parsing commandline arguments: unknown short flag '-c'
prometheus: error: unknown short flag '-c'

所以我删除了Digital Ocean在他们的例子中的最后几个参数,容器现在运行了。

-storage.local.path=/prometheus -storage.local.memory-chunks=10000

所以现在我的问题是,我是否需要指定这些配置,如果需要,语法是什么?

标签: windowsdockeryamlconfigprometheus

解决方案


能够使其在 Windows 环境中工作。

在同一网络中使用 docker 运行 prometheus:

检查这个:https ://docs.docker.com/config/thirdparty/prometheus/

脚步:

  • 项目清单

    • 单击工具栏中的 Docker 图标,选择 Preferences,然后选择 Daemon。单击高级。“metrics-addr”:“127.0.0.1:9323”,“实验”:true

    • 重启泊坞窗

    • 创建 C:\tmp\prometheus.yml [根据您的选择]
    • 在目标 --> 目标下:['docker.for.win.localhost:8001']
    • docker run --name container-name --network=network-name --mount type=bind,source=C:/tmp/prometheus.yml,destination=/etc/prometheus/prometheus.yml --publish published=9090,目标=9090,协议=tcp 舞会/普罗米修斯
    • 网址:本地主机:9090

希望这可以帮助。创建了一个示例工作项目:https ://github.com/mayank1989gupta/GradleAutoDeploy 您可以找到与此相关的更多详细信息。


推荐阅读