Docker for windows cannot edit file in the guest due to access rights

  • My computer is running Windows 10 and Docker for Windows

  • I am using docker volume to code faster

  • the code is on the windows side. In the docker-compose.yaml I mount my workspace on the host tho the root of the apache server on the guest

volumes:
    - ./:/var/www/html
  • When I create the file web\modules\custom\hello_world\hello_world.info.yml on the host that file replicates on the guest side but remains empty:
PS C:\Users\jeanp\CONSULTANT\dockertest> docker exec -it my_drupal9_project_nginx /bin/bash

/var/www/html$ ls -al web/modules/custom/hello_world/
total 8
drwxr-xr-x    2 root     root          4096 Aug  3 16:46 .
drwxr-xr-x    3 root     root          4096 Aug  3 16:46 ..
-rwxr-xr-x    1 root     root             0 Aug  3 16:46 hello_world.info.yml
  • (hello_world.info.yml has 0 bytes length and can be edited only by root)

    • On the guest side, when I try to edit hello_world.info.yml I cannot save it because it is marked as read-only
web/modules/custom/hello_world/hello_world.info.yml [Readonly] 0/0 100%
  • On the guest side I asked who am I the answer is wodby:
/var/www/html$ whoami
wodby
  • the other files on in the image on the guest belongs to wodby

/var/www/html$ ls -al web

total 84

drwxr-xr-x    7 wodby    wodby         4096 Jul 22 02:17 .

drwxr-xr-x    4 wodby    wodby         4096 Jul 31 12:04 ..

-rw-r--r--    1 wodby    wodby         1025 Jul 22 02:17 .csslintrc

-rw-r--r--    1 wodby    wodby          151 Jul 22 02:17 .eslintignore

-rw-r--r--    1 wodby    wodby           41 Jul 22 02:17 .eslintrc.json

-rw-r--r--    1 wodby    wodby         2314 Jul 22 02:17 .ht.router.php

-rw-r--r--    1 wodby    wodby         7572 Jul 22 02:17 .htaccess

-rw-r--r--    1 wodby    wodby           94 Jul 22 02:17 INSTALL.txt

-rw-r--r--    1 wodby    wodby         3205 Jul 22 02:17 README.md

-rw-r--r--    1 wodby    wodby          315 Jul 22 02:17 autoload.php

drwxr-xr-x   12 wodby    wodby         4096 Jul 20 21:42 core

-rw-r--r--    1 wodby    wodby         1507 Jul 22 02:17 example.gitignore

-rw-r--r--    1 wodby    wodby          549 Jul 22 02:17 index.php

drwxr-xr-x    3 wodby    wodby         4096 Aug  3 16:46 modules

drwxr-xr-x    2 wodby    wodby         4096 Jul 22 02:17 profiles

-rw-r--r--    1 wodby    wodby         1586 Jul 22 02:17 robots.txt

drwxr-xr-x    3 wodby    wodby         4096 Jul 22 02:17 sites

drwxr-xr-x    2 wodby    wodby         4096 Jul 22 02:17 themes

-rw-r--r--    1 wodby    wodby          804 Jul 22 02:17 update.php

-rw-r--r--    1 wodby    wodby         4016 Jul 22 02:17 web.config

My question is the following:

how to make that on the guest the files created through synchronisation from the host belongs to wodby and not root ?