I must update my .env file with this: DB_HOST=mysql
Yes, or pgsql if you use postgresql
Please correct your post to have a look to your setup, but the standard one works with this setting.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I run my project using Laravel 8 and Docker.
When I am inside Docker container and run DB related artisan commands I must update my .env file with this:
DB_HOST=mysql (service name from docker-compose.yml)
If I leave it like that I will get error trying to access website on 127.0.0.0.1:8000 and to fix it I need to go back again to .env and change DB_HOST to:
DB_HOST=127.0.0.1
Is something missing in my docker-compose.yml file in order to avoid keep editing .env? What am I doing wrong?
docker-compose.yml: https://www.codepile.net/pile/M1V6Dk1q
Thanks!
Please or to participate in this conversation.