I’m trying to connect my Dockerized Laravel application to a MySQL database using Docker Compose. I’ve mounted the .env
file that contains the DB_DATABASE variable
, but I’m still encountering the error:
docker-compose.yaml
Error
Here’s my setup:
- I have a Laravel project with a
.env
file containing DB_DATABASE and other environment variables. - I have a docker-compose.yml file that defines a service for MySQL and references the environment variables from .env.
- I’ve mounted the.env file into the container using the volumes section in docker-compose.yml.
My question is:
- How can I make mysql environment use the ${DB_DATABASE} from Laravel’s
.env
. Are there any known issues with this approach?