Wordpress on Docker: Could not create directory on mounted volume
Looking at your error message i come to the conclusion that you are trying to install a plugin or update wordpress itself
This issue is slightly tricky to figure out.
executing chown -R www-data:www-data /var/www
to set correct user:group permissions should technically solve it, however ..
On a new wordpress install the upload
& plugins
folder does not yet exist and therefore when installer trying to create a plugins/subfolder
it will throw the error.
How to Fix Wordpress / Docker Plugin install Permission issue
Fixing this issue is however quite easy once grasping it.
Option A
in your .Docker
file add following towards the very end but before any [CMD]
command.
RUN mkdir /var/www/html/wp-content/plugins
RUN mkdir /var/www/html/wp-content/uploads
RUN chown -R www-data:www-data /var/www
RUN find /var/www/ -type d -exec chmod 0755 {} \;
RUN find /var/www/ -type f -exec chmod 644 {} \;
Option B
ssh in to your docker containerdocker exec -it <container_name> /bin/bash
If you don't know the container name find it withdocker ps
Simply run same commands as in example above$ mkdir /var/www/html/wp-content/plugins
$ mkdir /var/www/html/wp-content/uploads
$ chown -R www-data:www-data /var/www
$ find /var/www/ -type d -exec chmod 0755 {} \;
$ find /var/www/ -type f -exec chmod 644 {} \;