Environment variables and secrets in Compose
Select an icon to see what it is.
Step 1 of 6
The CLI fills in ${VARIABLES}
Before it sends anything, the Compose CLI replaces ${DB_PASSWORD} in the file. It takes the value from your shell environment or from a .env file next to compose.yaml. dockerd never sees the ${...} text.
$ DB_PASSWORD=example docker compose up -d PrevNext
In the Compose CLI
compose.yaml: DB_PASSWORD: ${DB_PASSWORD}shell or .env: DB_PASSWORD=examplesent to dockerd: DB_PASSWORD=example