I’d been using Docker Toolbox (VirtualBox) for years. Finally moving over to Docker Desktop (WSL2), and have been having endless issues with permissions in mounted host directories.
Specifically, I’m trying to run GitHub - cytopia/devilbox: A modern Docker LAMP stack and MEAN stack for local development. It automatically creates vhosts for whatever folders you stick in /shared/httpd
. I mount my various project directories into there using relative paths in the docker-compose file, i.e.
httpd:
volumes:
- ../../../Work/Webroot/site1/htdocs:/shared/httpd/site1/htdocs:rw
- ../../../Personal/site2/htdocs:/shared/httpd/site2/htdocs:rw
...etc
This works with Docker Toolbox (provided I share the root drive with the VirtualBox VM). It also works with Docker Engine on Linux (it’s a dual boot machine, with the same NTFS partition mounted to Windows & Linux). But with Docker Desktop WSL2, the permissions of the files as viewed by the container seem to spontaneously change - literally from one minute to the next. As a quick example, here’s a screenshot where I used Docker Desktop’s “exec” tab to navigate to the shared folder from within Devilbox’s php container, and did ls -la
twice in a row (with no actions taken in between). You can see that the first time the files have permissions -----
, and the second time they have rwxrwxrwx
. I literally just did ls -la
twice back-to-back:
A similar behavior is observed when I try to access the in a browser - i.e. it will give “403 forbidden” one minute, then another minute it will load that php file, but fail to include some other php file farther down the tree.
I gave more in-depth repro steps on this github issue, but in the interim I was hoping someone might have an idea here, as I’ve put so many hours into messing with this I’m really at my wits end. No matter what I try, what Claude/ChatGPT suggest, what I find on forums…it just never seems to work properly with WSL. Sometimes the sites load perfectly, sometimes they give 403, sometimes half of the files will work and the other half will be permission denied.
- despite having changed literally nothing.
It was so simple & reliable on Docker Toolbox & on Linux. How can this be so hard on WSL2?
Help would be much appreciated.