I'm using the following Dockerfile/docker-compose.yml.
I'm including the volume "vendor" inside the "/var/www" volume. The "vendor" folder is being created automatically when running the docker-compose file. But it gets created with chown "root:root", while all other folders inside "/var/www" chowned to "www-data:www-data".
Any idea how I can fix it so that the "vendor" volume is also chowned by www-data by default?
Dockerfile
...
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
...
docker-compose.yml:
volumes:
- ./:/var/www
- vendor:/var/www/vendor
volumes:
vendor:
"ls -la" on the "/var/www" shows the following:
drwxr-xr-x 2 www-data www-data 0 Mar 15 20:40 .
drwxr-xr-x 2 www-data www-data 4096 Mar 15 20:28 ..
drwxr-xr-x 2 www-data www-data 0 Mar 15 20:42 test
drwxr-xr-x 2 root root 4096 Mar 15 20:38 vendor
Yes, you can use workaround, just create folder in Dockerfile, permission will be saved, as an example:
Dockerfile
FROM caa06d9c/support
RUN mkdir /var/www/ && chown 1000:1000 /var/www
CMD [ "sleep", "9999" ]
Docker Compose version: "3.2"
services:
srv:
image: temp
volumes:
- vendor:/var/www/
volumes:
vendor:
Output
drwxr-xr-x 3 root root 4096 Jul 5 2018 spool
drwxrwxrwt 2 root root 4096 Jul 5 2018 tmp
drwxr-xr-x 2 1000 1000 4096 Mar 15 21:06 www