【问题标题】:How to set access right on docker volume如何在 docker 卷上设置访问权限
【发布时间】:2022-08-16 23:56:37
【问题描述】:

这是一个简单的虚拟 docker-compose :

version: \'2.4\'
services:
  webserver:
    image: \"webserver:latest\" // apache, nginx, caddy, whatever
  volumes:
    - \"shared_storage:/app/storage/shared\"

  analyser:
    image: \"custom:latest\" // any custom script doing stuff on a volume
  volumes:
    - \"shared_storage:/local/storage/shared\"

volumes:
  shared_storage

问题是,shared_storage 由root 拥有,权限为644(或我可以使用user: 设置的任何用户),但网络服务器在内部以www-data 用户身份运行(我不知道提前身份证)。 如何授予网络服务器访问 shared_storage 卷的权限?

干杯

标签: docker docker-compose


【解决方案1】:

通过此设置,Webserver 和 Analyzer 应该对共享卷具有写入权限。 如果在构建期间有文件复制到卷中,您可以在构建期间在 dockerfile 中更改所有权,如下所示:

COPY /someDirectory /app/storage/shared
RUN chown www-data:www-data /app/storage/shared -R

您当然应该在容器的构建中执行此操作,该容器使用相应的文件路径复制文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-20
    相关资源
    最近更新 更多