I have recently switched back to Windows and am implementing a WSL2 setup (Ubuntu) for WordPress developmnent using docker compose:
services:
db:
command: '--default-authentication-plugin=mysql_native_password'
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=***
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=***
expose:
- 3306
- 33060
wordpress:
image: wordpress:latest
volumes:
- ./wp:/var/www/html
ports:
- 80:80
- 443:443
restart: always
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=***
- WORDPRESS_DB_NAME=wordpress
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- 8080:80
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: ***
volumes:
db_data:
The issue I’m facing is that I’m unable to write to the /wp/ folder with the Ubuntu user I have, whether via the command line or VSCode. So to be clear, my WSL2 filesystem looks like:
/home/myuser/sites/myproject/
docker-compose.yml
/wp/ # Docker volume mount
For example, I need to be able to clone Git repositories into the volume for the various plugins I work on, run build tooling etc.
My Ubuntu user has been added to the www-data
group --as this is the user/group owning the files – as well as the docker
group, but that hasn’t made any difference. I am convinced that I am missing something here?
Grateful for any pointers or suggestions for a better approach. I feel like I am missing something obvious!