/etc/prometheus/prometheus.yml에 대한 권한이 거부되었습니다. prom/prometheus 컨테이너를 배포할 수 없습니다.

/etc/prometheus/prometheus.yml에 대한 권한이 거부되었습니다. prom/prometheus 컨테이너를 배포할 수 없습니다.

저는 /etc/prometheus/prometheus.ymlAnsible을 통해 prom/prometheus 도커 이미지에 (기본) 구성 파일을 제공하기 위해 NFS 마운트를 사용하고 있습니다. 컨테이너를 배포한 후 컨테이너 로그에 다음 오류가 표시되고 몇 초 후에 컨테이너가 다시 시작됩니다.

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"

Docker 호스트(Raspberry Pi 4)에 탑재된 파일 시스템을 탐색하고 파일을 터치하여 prometheus.yml컨테이너를 시작한 사용자로서 읽을 수 있습니다.

다음은 내 플레이북의 관련 작업입니다. 문제는 CLI에서 컨테이너를 배포할 때도 동일합니다.아니요원격 파일 시스템은 at의 플레이북에 마운트되고 /mnt/prometheusat의 컨테이너에 볼륨으로 전달됩니다./etc/prometheus

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

프로메테우스/작업/main.yml( become: yes캐릭터를 호출하는 플레이북에 설정)

  - 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 마운트 대신 컨테이너와 공유할 로컬 디렉터리를 docker에 제공하여 이를 테스트했습니다. 이는 컨테이너와 성공적으로 공유되었으며 컨테이너가 시작되었습니다. NFS 문제를 지적하지만 아직 파악하지 못했습니다.

답변1

내 해결책을 찾았습니다여기에 게시된 답변. 좀 더 자세히내 블로그

관련 정보