gpt4 book ai didi

docker - Docker正在更改文件所有权和权限,为什么?

转载 作者:行者123 更新时间:2023-12-02 21:24:22 27 4
gpt4 key购买 nike

我有以下docker-compose.yml文件:

version: '2'
services:
php-fpm:
container_name: "php71-fpm-nginx"
build: php-fpm
ports:
- 8080:80
- 9002:9002
environment:
PHP_ERROR_REPORTING: 'E_ALL & ~E_DEPRECATED & ~E_NOTICE'
STATUS_PAGE_ALLOWED_IP: '127.0.0.1'
volumes:
- ~/dev:/data/www
links:
- db
db:
container_name: "db_mysql"
image: mysql
environment:
MYSQL_ROOT_PASSWORD: '1qazxsw2'
MYSQL_DATABASE: 'nortwind'
MYSQL_USER: 'db_user'
MYSQL_PASSWORD: '1qazxsw2'
volumes:
- ./dev/northwindSQL:/docker-entrypoint-initdb.d
- ~/data/db:/var/lib/mysql
elk:
container_name: "elk"
image: willdurand/elk
ports:
- 81:80
volumes:
- ./elk/logstash:/etc/logstash
- ./elk/logstash/patterns:/opt/logstash/patterns
volumes_from:
- php-fpm

一切工作正常,但是一旦我运行 docker-compose up -d --build命令,容器就会在 ~/dev上启动主机中的所有权和权限,如下所示:
$ ls -la ~/dev/
total 96
drwxrwxr-x 11 80 80 4096 Dec 15 14:36 .
drwx------. 40 rperez rperez 4096 Dec 15 14:26 ..
drwxr-xr-x 5 80 80 4096 Mar 13 2015 css
-rw-r--r-- 1 80 80 189 Mar 10 2016 DEMO_NOTES.TXT

这是预期的行为吗?这是来自 Dockerfile吗?有任何想法吗?

最佳答案

volumes take the ownership of whatever is already at the path in the container. If the location in the container is owned by root, then the volume will get root. If the location in the container is owned by something else, the volume will get that.

关于docker - Docker正在更改文件所有权和权限,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41172253/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com