Skip to main content
You will often see, when for example configuring providers, that the environment variables will look like this:
You have 2 options on how to set these variables in your docker-compose.yml file.

Option 1: Direct in docker-compose.yml

You can set them directly in the environment section of the service.

Option 2: Using a .env file

You can use a .env file to set the variables. docker-compose.yml:
.env:

Option 3: Combine both

You can also use both! docker-compose.yml:
.env:
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.