DEV Community

Discussion on: The beauty of Docker for local Laravel development

Collapse
 
_devlim profile image
I'M DEVLIM ⛱️

Files generate in /src folder when execute artisan command inside php container is own by root,
example, running following command

docker-compose exec php php /var/www/artisan make:controller ExampleController
Enter fullscreen mode Exit fullscreen mode

will generate ExampleController.php on host machine and file is own by root.

Any idea how to avoid this?

Collapse
 
robertocifuentes profile image
Roberto Cifuentes

I'm sorry if this is too late, but hopefully will help others, here's my workaround to solve the file owner issue, first you have to find-out whats your uid (normaly 1000):

  • in the terminal type id. The result will be something like:
$ id
uid=1000(roberto) gid=1000(roberto) grou [...]
Enter fullscreen mode Exit fullscreen mode
  • execute the php service as your uid:gid in your docker-compose.yml
services:
  php:
    [...]
    user: '1000:1000'
    [...]
Enter fullscreen mode Exit fullscreen mode