php artisan serve 在docker中不能读取系统环境变量
在docker里下面运行
php artisan octane:start --host=0.0.0.0 --port=9000
可以读取 REDIS_HOST=192.168.0.251
但运行
php artisan serve --host=0.0.0.0 --port=9000
不能读取到 REDIS_HOST=192.168.0.251
却读到了 REDIS_HOST=127.0.0.1
REDIS_HOST=192.168.0.251 是在docker ENV里设置的
$process = $this->startProcess($hasEnvironment);
/vendor/laravel/framework/src/illuminate/Foundation/Console/ServeCommand.php 57行 $hasEnvironment 改成false就可以了 有没有其他方法
php -S 0.0.0.0:9000 server.php
这样可以
推荐文章: