From 5f4848e08dc97e85d343b4323be58bf1e9c4cfd1 Mon Sep 17 00:00:00 2001 From: Kristin Martin Date: Wed, 29 Jul 2026 15:25:52 +0000 Subject: [PATCH] Show syntax for multiple build secrets The doc noted you can mount and pass multiple secrets but never showed how. Add explicit examples for mounting several secrets in a Dockerfile and passing several --build-secret flags to fly deploy. --- apps/build-secrets.html.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/build-secrets.html.md b/apps/build-secrets.html.md index 32b993fac2..3547da4b17 100644 --- a/apps/build-secrets.html.md +++ b/apps/build-secrets.html.md @@ -27,6 +27,15 @@ RUN --mount=type=secret,id=MY_SUPER_SECRET \ This creates a new file when running `docker build`. Secrets are stored in the `/run/secrets` directory. The file name is the `id` you passed when mounting the secret. The content of that file contains the value of the secret. +To mount more than one secret, add a `--mount` line for each: + +```dockerfile +RUN --mount=type=secret,id=SECRET_ONE \ + --mount=type=secret,id=SECRET_TWO \ + SECRET_ONE="$(cat /run/secrets/SECRET_ONE)" \ + SECRET_TWO="$(cat /run/secrets/SECRET_TWO)" some_command +``` + The `--mount` directive is not a shell command, so there's no need to add `&&` after it as you commonly see when chaining commands. ## Secret values @@ -34,11 +43,18 @@ The `--mount` directive is not a shell command, so there's no need to add `&&` a You need to provide the values of the mounted secrets when runningĀ `fly deploy`: ```bash -# Note: You can pass multiple secrets if you need fly deploy \ --build-secret MY_SUPER_SECRET=some_value ``` +To pass more than one secret, repeat the `--build-secret` flag: + +```bash +fly deploy \ + --build-secret SECRET_ONE=value_one \ + --build-secret SECRET_TWO=value_two +``` + ## Testing build secrets locally If you want to test your Docker build locally (before deploying to Fly.io), the commands to do so would look something like this: