What are Compose `secrets` and `configs`?
AdvancedConceptDocker Compose
Answer
They mount files read-only into containers at /run/secrets/<name> or a given path, sourced from a file or env var, avoiding secrets in environment. Many official images support *_FILE variables (e.g., POSTGRES_PASSWORD_FILE).
services:
db:
image: postgres:16
environment: { POSTGRES_PASSWORD_FILE: /run/secrets/dbpw }
secrets: [dbpw]
secrets:
dbpw:
file: ./dbpw.txt
More on Docker Compose
What is Docker Compose and what problem does it solve?Beginner`docker-compose` vs `docker compose`?BeginnerShow a minimal Compose file with a web app and a database.BeginnerWhat does `depends_on` guarantee?IntermediateHow do containers in Compose reach each other?BeginnerHow does Compose choose the project name and why does it matter?Intermediate