From e6847231e20eb2a6fdcdbc55ac1cebd9a98e62cc Mon Sep 17 00:00:00 2001 From: Cesar Fernando Bonilla Date: Mon, 15 Jul 2024 03:14:10 -0600 Subject: [PATCH] docs(compose): Inlude example for build secrets on the use-secrets doc (#20403) * docs: Inlude example for build secrets * Apply suggestions from code review --------- Co-authored-by: Allie Sadler <102604716+aevesdocker@users.noreply.github.com> --- content/compose/use-secrets.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/content/compose/use-secrets.md b/content/compose/use-secrets.md index 1bf3e64636..5aa34d67fe 100644 --- a/content/compose/use-secrets.md +++ b/content/compose/use-secrets.md @@ -84,7 +84,25 @@ In the advanced example above: > > The `_FILE` environment variables demonstrated here are a convention used by some images, including Docker Official Images like [mysql](https://hub.docker.com/_/mysql) and [postgres](https://hub.docker.com/_/postgres). +### Build secrets + +In the following example, the `npm_token` secret is made available at build time. It's value is taken from the `NPM_TOKEN` environment variable. + +```yaml +services: + myapp: + build: + secrets: + - npm_token + context: . + +secrets: + npm_token: + environment: NPM_TOKEN +``` + ## Resources - [Secrets top-level element](compose-file/09-secrets.md) - [Secrets attribute for services top-level element](compose-file/05-services.md#secrets) +- [Build secrets](https://docs.docker.com/build/building/secrets/)