用例。为什么这很重要?
centos7 + docker-ce + 普罗米修斯
当我运行 docker-compose 时,容器承诺下降
查看日志 docker Bug 报告
############################ 普罗米修斯_1 | ts=2022-12-15T10:14:55.536Z caller=query_logger.go:91 level=error 组件=activeQueryTracker msg="打开查询日志文件时出错" file=/prometheus/queries.active err="open /prometheus/queries .active:权限被拒绝” 普罗米修斯_1 |恐慌:无法创建 mmap-ed 活动查询日志 ##############################
我认为这是一个卷权限问题,我更改了权限,问题仍然存在
当我尝试将 prometheus 数据目录从主机挂载到容器时(而不是使用预定义的卷)时,我遇到了
prometheus:v2.37.7
的问题。
您可以添加一个 init 容器来修复
user: root
目录的目录权限,而不是将 /prometheus
添加到 docker compose,如下所示:
init_prometheus:
image: prom/prometheus:v2.37.7
user: root
entrypoint:
- /bin/sh
- -c
- |
chown -R 65534:65534 /prometheus
volumes:
- /data/prometheus:/prometheus
prometheus:
image: prom/prometheus:v2.37.7
restart: unless-stopped
volumes:
- /data/prometheus:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--web.enable-lifecycle'
ports:
- "9090:9090"
depends_on:
- init_prometheus
您正在将文件夹从容器安装到您的用户空间,prometheus 无法访问它。
有有是一个更好的解决方案,但以下对我有用:
services:
prometheus:
image: prom/prometheus
user: root
我的 docker run 命令需要以下内容
--用户“$(id -u)