From 95a88ccfc007ad396c118151fbc873707ef42fdc Mon Sep 17 00:00:00 2001 From: Dean Chen <862469039@qq.com> Date: Tue, 18 Aug 2026 00:44:48 +0500 Subject: [PATCH 1/2] docs: show --template-driver for swarm secrets Signed-off-by: Dean Chen <862469039@qq.com> --- content/manuals/engine/swarm/secrets.md | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/content/manuals/engine/swarm/secrets.md b/content/manuals/engine/swarm/secrets.md index 591fd652439d..2028e020b1f8 100644 --- a/content/manuals/engine/swarm/secrets.md +++ b/content/manuals/engine/swarm/secrets.md @@ -264,6 +264,39 @@ real-world example, continue to $ docker secret rm my_secret_data ``` +### Example: Use a templated secret + +Secrets support the same Go templates as [configs](configs.md#example-use-a-templated-config). +Pass `--template-driver golang` when you create the secret. The template is +rendered when the container is created. + +1. Save the following into a new file `db-password.tmpl`. + + ```text + {{ env "DB_PASSWORD" }} + ``` + +2. Create the secret and a service that has the environment variable and + the secret. + + ```console + $ docker secret create --template-driver golang db-password db-password.tmpl + + $ docker service create \ + --name db \ + --env DB_PASSWORD="s3cret" \ + --secret source=db-password,target=db_password \ + redis:alpine + ``` + +3. The task reads the rendered value, not the template text. + + ```console + $ docker container exec $(docker ps --filter name=db -q) cat /run/secrets/db_password + + s3cret + ``` + ### Simple example: Use secrets in a Windows service This is a very simple example which shows how to use secrets with a Microsoft From 4090ccf51e2d6c39b45180f4a01549d611620980 Mon Sep 17 00:00:00 2001 From: Dean Chen <862469039@qq.com> Date: Tue, 18 Aug 2026 03:09:32 +0500 Subject: [PATCH 2/2] docs: avoid Vale flag on 'templated' Signed-off-by: Dean Chen <862469039@qq.com> --- content/manuals/engine/swarm/secrets.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/manuals/engine/swarm/secrets.md b/content/manuals/engine/swarm/secrets.md index 2028e020b1f8..fd22c69ccaa9 100644 --- a/content/manuals/engine/swarm/secrets.md +++ b/content/manuals/engine/swarm/secrets.md @@ -264,7 +264,7 @@ real-world example, continue to $ docker secret rm my_secret_data ``` -### Example: Use a templated secret +### Example: Use a Go template for a secret Secrets support the same Go templates as [configs](configs.md#example-use-a-templated-config). Pass `--template-driver golang` when you create the secret. The template is