首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >拒绝/etc/prometheus/prometheus.yml;无法部署prom/prometheus容器

拒绝/etc/prometheus/prometheus.yml;无法部署prom/prometheus容器
EN

Unix & Linux用户
提问于 2020-10-28 18:49:09
回答 1查看 6.6K关注 0票数 1

我使用NFS挂载将/etc/prometheus/prometheus.yml (默认)配置文件提供给prom/prometheus映像,所有这些都是通过Ansible提供的。部署容器时,我在容器日志中得到以下错误,几秒钟后容器重新启动。

level=error ts=2020-10-28T16:01:04.432Z caller=main.go:290 msg="Error loading config (--config.file=/etc/prometheus/prometheus.yml)" err="open /etc/prometheus/prometheus.yml: permission denied"

我可以在我的停靠主机( Raspberry 4)上浏览挂载的文件系统,触摸文件,并以启动容器的用户身份读取prometheus.yml

下面是我的剧本中的相关任务,当从CLI部署容器时,问题是相同的,而不使用安装在/mnt/prometheus上的远程文件系统,并在/etc/prometheus作为卷传递给容器时,问题是相同的。

docker run -p 9090:9090 -v /mnt/prometheus:/etc/prometheus prom/prometheus

prometheus/tasks/main.yml (become: yes在调用此角色的剧本中设置)

代码语言:javascript
复制
  - name: "Create mountpoint"
    file: 
        path: "{{ prometheus_mount_path }}"
        state: directory
        mode: 0777
        owner: root
        group: users
        

  - name: "Mount nfs drive for prometheus filesystem"
    mount: 
        path: "{{ prometheus_mount_path }}"
        src: "{{ nfs_server }}:{{ prometheus_nfs_path }}"
        state: mounted
        fstype: nfs
        
  - name: "Create prometheus.yml in mountpoint from template"
    template: 
        src: prometheus.yml.j2
        dest: "{{ prometheus_mount_path }}/prometheus.yml"

        
  - name: "Deploy prometheus container"
    docker_container:
        name: prometheus
        image: prom/prometheus:latest
        restart_policy: always
        state: started
        network_mode: host
        hostname: prometheus
#        exposed_ports: 9090
        published_ports: 9090:9090
        user: 995:1002
        mounts: 
        volumes:
            - "{{ prometheus_mount_path }}:/etc/prometheus"
        comparisons:
            '*': ignore
            env: strict

知道什么会导致或如何从容器中解决permission denied问题吗?

编辑:我通过提供一个本地目录来与容器共享而不是NFS挂载来进行测试。这已成功地与容器共享,并启动了容器。指出NFS的问题,但我还没有弄清楚。

EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2020-11-10 16:00:16

我找到了我的解决方案和把答案贴在这里。在我的博客文章中略为详细介绍

票数 1
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/616911

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档