Secrets 顶级元素
目录
机密是 配置的一种变体,专注于敏感数据,并对此用途有特定的限制。
服务只有在 services 顶级元素内通过 secrets 属性 显式授权时才能访问机密信息。
顶层的 secrets 声明定义或引用了授予 Compose 应用程序中服务的敏感数据。密钥的来源是 file 或 environment。
file: 密钥已使用指定路径下文件的内容创建。environment:使用环境变量的值创建了 Secret。
示例 1
server-certificate 密钥在应用部署时创建为 <project_name>_server-certificate,
通过将 server.cert 的内容注册为平台密钥。
secrets:
server-certificate:
file: ./server.cert示例 2
token secret is created as <project_name>_token when the application is deployed,
by registering the content of the OAUTH_TOKEN environment variable as a platform secret.
secrets:
token:
environment: "OAUTH_TOKEN"其他资源
如需更多信息,请参阅 如何在 Compose 中使用 secrets。