我正在尝试使用Prometheus docker container通过NFS卷将具有持久性数据的Docker named volume部署。我正在使用Ansible进行部署,因此我将发布Ansible配置,但是我已经使用Docker的CLI命令执行了相同的操作,并且在这种情况下也存在问题。
当我部署容器并检查容器docker logs
时,我发现/etc/prometheus
被适当共享并附加到容器上。但是,/prometheus
是容器存储相关数据库和指标的位置,它拒绝了权限。
根据this answer,/prometheus
必须chown
被授予任何人。启动时似乎不会在容器内发生这种情况。
这是我的Ansible角色创建的卷:
- name: "Creates named docker volume"
docker_volume:
volume_name: prometheus_persist
state: present
driver_options:
type: nfs
o: "addr={{ nfs_server }},rw,nolock"
device: ":{{ prometheus_nfs_path }}"
这等效于此Docker CLI命令:
docker volume create -d local -o type=nfs -o o=addr={{ nfs_server }},rw -o device=:{{ prometheus_nfs_path }} prometheus_persist
这是我的容器部署节
- name: "Deploy prometheus container"
docker_container:
name: prometheus
# hostname: prometheus
image: prom/prometheus
restart_policy: always
state: started
ports: 9090:9090
user: ansible:docker
volumes:
- "{{ prometheus_config_path }}:/etc/prometheus"
mounts:
- source: prometheus_persist
target: /prometheus
read_only: no
type: volume
comparisons:
env: strict
这等效于此Docker CLI命令:
docker run -v prometheus_persist:/prometheus -v "{{ prometheus_config_path }}:/etc/prometheus" -p 9090:9090 --name prometheus prom/prometheus
同样,容器日志在部署时指示对/prometheus
的权限被拒绝。我已经通过将prometheus_persist
命名卷安装在通用Ubuntu容器上进行了测试,它可以很好地安装,并且我可以在其中插入touch
个文件。有关如何解决此问题的任何建议?
答案 0 :(得分:0)
事实证明这是NFS压缩的问题。在我的情况下,NFS导出器是一个旧的Synology,它不允许设置select W.WeekID, S.StudentID
from [Week] W
cross join Student S
where not exists (select 1 from TimeSheet T where T.StudentID = S.StudentID and T.WeekID = W.WeekID);
。但是,将所有用户映射到NFS共享上的管理员即可解决此问题。