Docker Compose file · Environment and secrets

Use secrets

Mount a secret as a file under /run/secrets rather than an environment variable.

services:
  api:
    secrets:
      - db_password
secrets:
  db_password:
    file: ./secrets/db_password.txt

Official Docker Compose file documentation

More environment and secrets commands

All environment and secrets commands · Docker Compose file cheatsheet

Was this page helpful?