0

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.

Michele Carino
  • 914
  • 2
  • 10
  • 25
  • 1
    [What is the (best) way to manage permissions for Docker shared volumes?](https://stackoverflow.com/questions/23544282/what-is-the-best-way-to-manage-permissions-for-docker-shared-volumes) has some good discussion of managing the container process's user ID to match the bind-mounted directory's owner. – David Maze Jun 29 '21 at 10:51

0 Answers0