I'm a bit lost with owner and rights inside a docker container, and I need help regarding the creation of a folder.
I'm mounting in a container a local directory images
. When I launch a bash inside my container, here is the rules of my folder:
drwxrwxr-x 2 1000 1000 4096 Apr 24 21:43 images
My php code tries to create a folder:
$prodid = mysqli_insert_id($conn);
$targetDir = "../../theme/modules/products/images/".$prodid."/";
$oldumask = umask(0);
mkdir($targetDir, 0755);
But I receive this error:
Warning
: mkdir(): Permission denied in
/var/www/html/modules/product/product_new.php
I suppose the owner of this folder should be www-data:www-data
(and not even sure about that), so I tried to add in my dockerfile:
FROM php:7.3-apache
...
RUN chown www-data:www-data /var/www/html/theme/modules/products/images
and my docker-compose:
version: "2"
services:
www:
build: .
ports:
- "80:80"
volumes:
- ./www/.htaccess:/var/www/html/.htaccess
- ./www/lib:/var/www/html/lib
- ./www/modules:/var/www/html/modules
- ./www/theme:/var/www/html/theme
- ./www/index.php:/var/www/html/index.php
- product-images:/var/www/html/theme/modules/products/images
links:
- db
networks:
- default
db:
image: mariadb:10.2
volumes:
- ./dump:/docker-entrypoint-initdb.d
- mariadb-data:/var/lib/mysql
networks:
- default
phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- db:db
ports:
- 8001:80
volumes:
mariadb-data:
product-images:
Rules are set, error is gone, but the folder is not created. i don't know what should be the ower/group or rights for this folder to allow php to create a folder.
When I docker-inspect
the volume:
docker inspect arcadust_product-images
[
{
"CreatedAt": "2019-07-30T15:45:31+02:00",
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/arcadust_product-images/_data",
"Name": "arcadust_product-images",
"Options": {},
"Scope": "local"
}
]
What am I doing wrong?