Fre*_*ero 19 php laravel docker laravel-8 laravel-sail
我在 Windows 10 中遇到以下问题(在 Ubuntu 中工作正常):
我正在 Laravel 8 中使用 Sail 当我APP_PORT在.env...上创建变量时
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_PORT=3000
Run Code Online (Sandbox Code Playgroud)
...并启动网络,sail up我收到此错误:
services.laravel.test.ports contains an invalid type, it should be a number, or an object
Run Code Online (Sandbox Code Playgroud)
这就是docker-compose.yml看起来的样子
version: '3'
services:
laravel.test:
build:
context: ./docker/8.0
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.0/app
ports:
- '${APP_PORT:-80}:80'
...
Run Code Online (Sandbox Code Playgroud)
我知道我可以直接输入ports: - '3000:80',但由于我在团队中工作并且该php artisan sail:install命令将覆盖该docker-compose.yml文件,因此我不想更改该docker-compose.yml文件。
提前致谢。
zer*_*ro8 18
驶入
sudo APP_PORT=3001 ./vendor/bin/sail up
Run Code Online (Sandbox Code Playgroud)
那是我做事的唯一方式就是工作。仍然不知道为什么其他配置不允许在 .env 中使用它
Bis*_*hal 17
\xe2\x80\x99s 无需更改 docker-compose.yml 文件,只需在 .env 文件中添加一行即可:
\n在你的 .env 文件中添加一行
\nAPP_PORT=3001 //or instead of 3001 any other port number of your choice
重启赛欧
\nsail up
现在您应该能够使用您在步骤 1 中设置的端口号访问您的应用程序
\nhttp://localhost:3001
Windows 10 上的 Laravel Sail (Docker) 的解决方案是将.envEOL 从 CRLF 更改为 LF。我发现它是因为我试图解决另一个问题的警告:
./.env: line X: $'\r': command not found
/usr/bin/env: bash: No such file or directory
Run Code Online (Sandbox Code Playgroud)
在解决 EOL 冲突后,该sail up命令能够读取所有环境变量。我还在以下文件中将 EOL 更改为 LR:
.env
artisan
docker/7.4/start-container
docker/8.0/start-container
vendor/laravel/sail/runtimes/8.0/start-container
vendor/laravel/sail/runtimes/7.4/start-container
Run Code Online (Sandbox Code Playgroud)
很明显为什么这个问题在 Ubuntu 上不存在。
| 归档时间: |
|
| 查看次数: |
25836 次 |
| 最近记录: |