我正在尝试使用以下命令启动Prometheus docker image
docker run -p 9090:9090 -v /prometheus-data prom/prometheus --config.file=/prometheus-data/prometheus.yml它给出了以下错误-
level=info ts=2019-04-04T07:00:57.825748769Z caller=main.go:285 msg="no time or size retention was set so using the default time retention" duration=15d
level=info ts=2019-04-04T07:00:57.825814174Z caller=main.go:321 msg="Starting Prometheus" version="(version=2.8.1, branch=HEAD, revision=4d60eb36dcbed725fcac5b27018574118f12fffb)"
level=info ts=2019-04-04T07:00:57.825837922Z caller=main.go:322 build_context="(go=go1.11.6, user=root@bfdd6a22a683, date=20190328-18:04:08)"
level=info ts=2019-04-04T07:00:57.825860337Z caller=main.go:323 host_details="(Linux 4.15.0-46-generic #49-Ubuntu SMP Wed Feb 6 09:33:07 UTC 2019 x86_64 66c91dea5c1a (none))"
level=info ts=2019-04-04T07:00:57.825884164Z caller=main.go:324 fd_limits="(soft=1048576, hard=1048576)"
level=info ts=2019-04-04T07:00:57.825903925Z caller=main.go:325 vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=2019-04-04T07:00:57.826527025Z caller=main.go:640 msg="Starting TSDB ..."
level=info ts=2019-04-04T07:00:57.826561753Z caller=web.go:418 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2019-04-04T07:00:57.832311812Z caller=main.go:655 msg="TSDB started"
level=info ts=2019-04-04T07:00:57.832352248Z caller=main.go:724 msg="Loading configuration file" filename=/prometheus-data/prometheus.yml
level=info ts=2019-04-04T07:00:57.83239727Z caller=main.go:509 msg="Stopping scrape discovery manager..."
level=info ts=2019-04-04T07:00:57.832408073Z caller=main.go:523 msg="Stopping notify discovery manager..."
level=info ts=2019-04-04T07:00:57.832414257Z caller=main.go:545 msg="Stopping scrape manager..."
level=info ts=2019-04-04T07:00:57.832420826Z caller=main.go:519 msg="Notify discovery manager stopped"
level=info ts=2019-04-04T07:00:57.832438255Z caller=main.go:505 msg="Scrape discovery manager stopped"
level=info ts=2019-04-04T07:00:57.832450272Z caller=manager.go:736 component="rule manager" msg="Stopping rule manager..."
level=info ts=2019-04-04T07:00:57.832467629Z caller=manager.go:742 component="rule manager" msg="Rule manager stopped"
level=info ts=2019-04-04T07:00:57.832470472Z caller=main.go:539 msg="Scrape manager stopped"
level=info ts=2019-04-04T07:00:57.934588178Z caller=notifier.go:521 component=notifier msg="Stopping notification manager..."
level=info ts=2019-04-04T07:00:57.934683234Z caller=main.go:708 msg="Notifier manager stopped"
level=error ts=2019-04-04T07:00:57.935159211Z caller=main.go:717 err="error loading config from \"/prometheus-data/prometheus.yml\": couldn't load configuration (--config.file=\"/prometheus-data/prometheus.yml\"): open /prometheus-data/prometheus.yml: no such file or directory"我仔细检查了目录和配置文件是否存在,并检查了目录和配置文件名中的拼写错误。
我是不是遗漏了什么?
我使用ubuntu 18.0.4
我检查了this解决方案,但它对我不起作用。
发布于 2019-04-04 15:09:46
尝试以下命令,而不是--config.file:
docker run -p 9090:9090 -d --mount type=bind,source=path/to/prometheus.yml,target=/etc/prometheus/prometheus.yml prom/prometheus这就是我在Ubuntu 18.04上的工作方式
发布于 2019-04-09 05:15:08
问题出在这里:
docker run -v /prometheus-data ...您创建了数据卷并将其挂载到/prometheus- 中的容器中。
装入卷时,该卷可能是命名卷,也可能是匿名卷。匿名卷在第一次挂载到容器中时没有明确的名称,因此Docker为它们提供了一个随机名称,该名称在给定的Docker主机中是唯一的。除了名称之外,命名卷和匿名卷的行为方式也是相同的。
所以这个匿名卷与您在同名主机上的目录没有任何关系。或者更准确地说,容器中的卷掩蔽了主机目录。无论如何,从你的容器内部看,这个目录是空的。
如果要将主机目录绑定到容器中的目录,则必须提供两个参数:第一个参数是主机目录(source),第二个参数是容器内的目录(target)
docker run -v /prometheus-data:/prometheus-data ...为了避免与-v语法混淆,最好使用--mount
装载最初,-v或--
标志用于独立容器,--mount标志用于群服务。但是,从Docker 17.06开始,您还可以对独立容器使用--mount。通常,--mount更加明确和详细。最大的区别是-v语法将所有选项组合在一个字段中,而--mount语法将它们分开。
https://stackoverflow.com/questions/55509726
复制相似问题