Docker Compose

Compose secrets

Provide a file to selected services; Linux short syntax exposes it below /run/secrets. Local file-backed mounts do not guarantee encrypted storage or automatic rotation. Never print real values. A successful absence check is limited to the inspected path and service.

Formal Syntax & Structure

docker syntaxdocker
secrets: { NAME: { file: PATH } }

Parameters & Attributes

NameTypeDescription
NAMEstringSecret identifier
PATHstringAuthorized source file

Working Example

Example Snippetdocker
secrets:  demo_token:    file: ./demo-token.txt
Docker Reference