Py学习  »  docker

docker compose:绑定装载时的目录权限错误

pkaramol • 4 年前 • 813 次点击  

想把一个 docker-compose 栈与 prometheus 图像(尽管实际服务与此无关)。

我创建了以下dir以保持 普罗米修斯 数据。

$ ls -ald /prometheus_data/
drwxrwxr-x 3 root root 4096 Jan 17 07:24 /prometheus_data/

并在中设置服务 Docker合成 如下:

prometheus:
    image: prom/prometheus
    volumes:
        - ./prometheus/:/etc/prometheus/
        - /prometheus_data:/prometheus_data:rw
    command:
        - '--config.file=/etc/prometheus/prometheus.yml'
        - '--storage.tsdb.path=/prometheus_data'
        - '--storage.tsdb.retention=4d'
        - '--web.console.libraries=/usr/share/prometheus/console_libraries'
        - '--web.console.templates=/usr/share/prometheus/consoles'
    ports:
        - 9090:9090
    depends_on:
        - cadvisor
    restart: always

但服务失败:

prometheus_1     | level=error ts=2019-01-17T09:35:09.200050622Z caller=main.go:579 err="Opening storage failed open DB in /prometheus_data: open /prometheus_data/146791472: permission denied"
prometheus_1     | level=info ts=2019-01-17T09:35:09.20007784Z caller=main.go:581 msg="See you next time!"

服务不是由 root 用户?

为什么会出现上述权限错误?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/43770
 
813 次点击  
文章 [ 1 ]  |  最新文章 4 年前
pkaramol
Reply   •   1 楼
pkaramol    5 年前

根据 Dockerfile 属于 prometheus 这个 USER 设置为 nobody .

因此,服务无法访问上述目录是有意义的。

所以问题是通过执行一个

chgrp -R nogroup /prometheus_data