如何更改docker-compose.yml中docker-compose.yml中已装载卷的权限? [英] How can I change permission of mounted volumes in docker-compose.yml from the docker-compose.yml?

查看:67
本文介绍了如何更改docker-compose.yml中docker-compose.yml中已装载卷的权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

version: '2'
services:
    web:
        build:
            context: ./
            dockerfile: deploy/web.docker
        volumes:
            - ./:/var/www
        ports:
            - "8080:80"
        links:
            - app

docker-compose up -d --build 时,如何自动更改权限( chmod )/var/www?

How can I change permission (chmod) /var/www automatically when docker-compose up -d --build?

推荐答案

从容器中的主机绑定挂载目录时,文件和目录将保留其在主机上的权限.这是设计使然:使用绑定安装时,您使容器可以从主机访问现有文件,而Docker不会对这些文件进行修改.这样做非常危险(例如,将主目录绑定安装会更改主机的主目录的文件权限,这可能导致您的计算机不再可用).

When bind-mounting a directory from the host in a container, files and directories maintain the permissions they have on the host. This is by design: when using a bind-mount, you're giving the container access to existing files from the host, and Docker won't make modifications to those files; doing so would be very dangerous (for example, bind-mounting your home-directory would change file permissions of your host's home directory, possibly leading to your machine no longer being usable).

要更改这些文件的权限,请更改其在主机上的权限.

To change permissions of those files, change their permissions on the host.

您可以在我在StackOverflow上发布的另一个答案中找到有关此问题的更多信息: https://stackoverflow.com/a/29251160/1811501

You can find more information on this in another answer I posted on StackOverflow: https://stackoverflow.com/a/29251160/1811501

这篇关于如何更改docker-compose.yml中docker-compose.yml中已装载卷的权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆