Docker 正在更改文件所有权和权限,为什么?
Docker is changing files ownership and permission, why?
我有以下 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-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.