Mounts a file-backed secret into the container.
Section: Configs and Secrets Patterns
Mount a secret file
yaml
yaml
services:
api:
image: myapi:latest
secrets:
- app_key
secrets:
app_key:
file: ./secrets/app_key.txtExplanation
Useful for credentials and tokens you do not want inline in YAML.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Configs and Secrets Patterns
Mount a config file
Provides a structured way to mount a config artifact.
Named volume for persistent data
Stores database data in a managed named volume.