moodlehq / moodle-php-apache

PHP + Apache docker images for Moodle development
61 stars 68 forks source link

How to configure the moodledata directory to a directory on my host? #157

Closed llagerlof closed 2 years ago

llagerlof commented 2 years ago

I managed to run this Moodle and everything is working fine, acessing a external database. But now I am trying to configure moodle to point the container' directory /var/www/moodledata to a directory on my host, let's say, /host/moodledata.

Ex:

This work (default moodledata inside the container):

$ docker run --name moodle402 -p 8080:80 -v $PWD:/var/www/html moodlehq/moodle-php-apache:7.4

This no work and I don't know why. Moodle show the error: error/An error occurred whilst communicating with the server

$ docker run --name moodle402 -p 8080:80 \
-v $PWD:/var/www/html \
-v /host/moodledata:/var/www/moodledata \
moodlehq/moodle-php-apache:7.4

My Moodle config:

$CFG->dataroot  = '/var/www/moodledata';

The directory /host/moodledata has full permissions (777).

So, is there some "right" way to have moodledata on my host?

andrewnicols commented 2 years ago

At a guess it's because the directory is mounted as root, Apache as run as a non-root user (www-data), and owned by your own user on the host.

This is a docker query but I suspect it will be solved by either: