I have the following problem in Windows 10 (in Ubuntu works properly):
I'm working in Laravel 8 with Sail
When I create the APP_PORT
variable on .env
...
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_PORT=3000
...and launch the web with sail up
I get this error:
services.laravel.test.ports contains an invalid type, it should be a number, or an object
This is how the docker-compose.yml
looks
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'
...
I know that I could just put ports: - '3000:80'
but since I'm working in team and the php artisan sail:install
command will overwrite the docker-compose.yml
file I don't wanna change the docker-compose.yml
file.
Thanks in advance.
run sail in
sudo APP_PORT=3001 ./vendor/bin/sail up
thats the only way i made is work. is still dont know why other configurations dont allow it in .env
There’s no need to change docker-compose.yml file, just adding a line on your .env file should work:
on your .env file add a line
APP_PORT=3001 //or instead of 3001 any other port number of your choice
restart Sail
sail up
Now you should be able to access your application with the port number you set on step 1
http://localhost:3001
The solution for Laravel Sail (Docker) on Windows 10 was changing the .env
EOL from CRLF to LF. I found it out because I was trying to resolve this warnings from another issue:
./.env: line X: $'\r': command not found
/usr/bin/env: bash: No such file or directory
After I resolved that EOL conflict the sail up
command was able to read all the enviroment variables. I also changed the EOL to LR in the following files:
.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
It's clear why this problem wasnt present on Ubuntu.
add to your .env:
SERVER_PORT=3001
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With