docker运行prometheus报错:error loading config from \"prometheus.yml\": couldn't load configuration

目录

prometheus.yml路径

原命令

报错

 解决

完整命令


prometheus.yml路径

/root/katy/prometheus/prometheus.yml

docker运行prometheus报错:error loading config from \

原命令

// --log.level=debug: log以debug模式输出
// --storage.tsdb.retention.time=3d: 数据保留时间为3天
docker run -d -p 9090:9090 -v /root/katy/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro prom/prometheus:latest --log.level=debug --storage.tsdb.retention.time=3d

报错

docker ps |grep prometheus根本没起起来。

从日志level可以看出我的log.level=dubug已经生效,并且还可以看到我设置的retention时间。

但在加载配置文件的时候就报错:

error loading config from \"prometheus.yml\": couldn't load configuration (--config.file=\"prometheus.yml\"): open prometheus.yml: no such file or directory

docker运行prometheus报错:error loading config from \

 解决

有大佬说-v是挂载目录,不能用文件,我操作了,效果一样的。

https://github.com/prometheus/prometheus/issues/5986

在命令后追加--config.file=/etc/prometheus/prometheus.yml,就解决了

完整命令

// --log.level=debug:日志以debug输出
// --storage.tsdb.retention.time=3d,数据保留3天
// --config.file=/etc/prometheus/prometheus.yml:这个其实是容器里面的默认路径,我也不知道为啥需要这个,反正我加了这个就解决了
docker run -d -p 9090:9090 -v /root/katy/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml --name prometheus  prom/prometheus:latest --log.level=debug --storage.tsdb.retention.time=3d --config.file=/etc/prometheus/prometheus.yml

 

你可能感兴趣的:(prometheus)