docker-compose.yml file.
Option 1: Direct in docker-compose.yml
You can set them directly in theenvironment section of the service.
Option 2: Using a .env file
You can use a.env file to set the variables.
docker-compose.yml:
Option 3: Combine both
You can also use both! docker-compose.yml:When using an .env file, you will need to transfer all environment variables from the docker-compose.yml file to the .env file.
An .env file will override any variables set in the .yml file.
Using an .env file for the DB / Redis won’t be necessary.

