Reputation: 2057
I want to setup a local Wordpress dev environment, so I'm trying out Docker for Windows and WSL. I've used standard images (wordpress:4.9.7, mysql:5.7 and phpmyadmin/phpmyadmin) and use docker-compose. I can get Wordpress running, but run into problems when I try to update or add plugins.
I have this in the Wordpress service section of the docker-compose.yml:
volumes:
- ./wp-content:/var/www/html/wp-content
This means that:
If I remove the volumes from docker-compose.yml I get write access back but I can't edit or persist the wp-content file from the host.
I just want an easy Wordpress dev environment. Is there a way to get this working with Docker for Windows, or will I have to go back to using a virtual machine?
EDIT: According to this it's not possible to host mount a volume with Docker for Windows and have anything but 755 permissions.
It doesn't specify whether the owner of the mounted volume within the container can be changed from root:root or not. I've tried various ways to do this within the running container (chown appears to fail silently), as well as trying various "user:..." additions to the docker-compose.yml but without success. If the owner of a shared volume cannot be set or modified then Wordpress cannot write to that shared volume.
One possible solution might be to use the mounted volume during development (i.e. when writing code in Sublime on the host in Windows), and then remove the mount whenever I need to give Wordpress write permissions (e.g. updating plugins or adding media - basically whenever it actually needs to run). Sounds pretty horrible, but seems like I have limited options.
Still would love a good Windows workflow if anyone has any other suggestions. My hope is that there is a way to change the owner of the mounted volume within the container. I haven't found anything saying definitively that this is or is not possible, so would love some guidance on this.
Upvotes: 1
Views: 1681
Reputation: 51876
There are a couple of options in here:
user: root
inside the compose file.FROM wordpress
and RUN chmod -R 766 /var/www/html/wp-content
docker exec --user root -it <container> bash
and run chmod -R 766 /var/www/html/wp-content
.Upvotes: 1