I'm using docker compose for local development, and I have this image php-apache that is an Alpine linux based docker image I use also in production.
In production /efs in an AWS elastic file system volume mounted on a Docker beanstalk. In local I'm simulating the situation by mounting a directory as volume:
volumes:
- ./docker/php-apache/local-efs:${PWS_VOLUME_PATH}
# where PWS_VOLUME_PATH=/efs
Given this as the container starts, apache user has not permission to write to the directory of the mounted volume, until I run following command:
docker-compose run --rm --entrypoint 'chmod -R 777 /efs' php-apache
This gives the apache user permission to write /efs.
Then if I want to have the directory writable from the host I have to launch:
sudo chown -R myuser:myuser ./docker/php-apache/local-efs
That returns back ownership to the host.
Need a clean and best if idiomatic solution to manage both, without changing the container image that is fine for production.
Thanks.