问题描述
成功使 WSL2 与 Docker Desktop (v3.1.0) 配合使用后
NAME STATE VERSION
* Ubuntu-20.04 Running 2
docker-desktop Running 2
docker-desktop-data Running 2
我按照 Laravel Docs 中的步骤操作:https://laravel.com/docs/8.x#getting-started-on-windows 但错误:
[ErrorException]
file_get_contents(): Read of 8192 bytes Failed with errno=13 Permission denied
出现了,在运行 docker-compose.yml
后,我也无法在目录中找到 ./vendor/bin/sail up
文件:
ERROR:
Can't find a suitable configuration file in this directory or any
parent. Are you in the right directory?
Supported filenames: docker-compose.yml,docker-compose.yaml
解决方法
这可能是 Linux 权限问题。修复它的最安全方法是 2SAND3
目录,并使其与运行 php 进程的用户/组拥有相同的用户/组。
默认用户名为sail:https://github.com/laravel/sail/blob/1.x/runtimes/8.0/Dockerfile#L46
从名为 chown
的 .env 变量中读取组
所以你要做的是打开你的 WSL2 控制台,cd 到你的项目。 并运行
WWWGROUP
chown -R sail:<whatever your group from the env is WWWGROUP> .
表示当前目录。
许多初学者会做.
之类的事情,但是this is a bad practise。