Docker + Windows + Prometheus : How/Where 提供配置文件

Docker + Windows + Prometheus : How/Where to supply the configuration files

我正在尝试传递我自己的 prometheus.yml 文件。我是 docker 的新手,我找到的示例都在 Linux 系统上,而我在 windows 上。 How/where 是提供我自己的 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: 驱动器,但我仍然无法将容器发送到 运行 .

docker 日志是这样说的:

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

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

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

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

能够在 windows 环境中工作。

对于 运行ning prometheus 与 docker 在同一网络中:

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

步数:

  • 列表项

    • 单击工具栏中的 Docker 图标,select 首选项,然后单击 select 守护进程。单击高级。 "metrics-addr":“127.0.0.1:9323”,"experimental":真

    • 重启docker

    • 创建 C:\tmp\prometheus.yml [根据您的选择]
    • 在目标下 --> 目标:['docker.for.win.localhost:8001']
    • docker 运行 --name container-name --network=network-name --mount type=bind,source=C:/tmp/prometheus.yml,destination=/etc/prometheus/prometheus.yml --publish published=9090,target=9090,protocol=tcp prom/prometheus
    • URL: localhost:9090

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

DO 的那个教程已经过时了。基本上,自 v2.0 以来,Prometheus 中的相关内容 were changed:

  • 新的 CLI 选项格式:双破折号表示长选项,例如 --config.file
  • 选项 storage.local.*(和其他一些)已删除

正确的命令是:

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

将命令更改为:

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

您只需要在 -config 之前添加一个 - 即可使 -config 变为 --config

它对我有用。