@@ -17,6 +17,7 @@ package pass
1717import (
1818 "context"
1919 "os"
20+ "strings"
2021
2122 "github.com/spf13/cobra"
2223 "go.opentelemetry.io/otel"
@@ -47,10 +48,73 @@ Examples:
4748{{.Example}}{{end}}
4849`
4950
51+ const rootExample = `
52+ ### Using keychain secrets in containers
53+
54+ Create a secret:
55+
56+ ` + "```" + `console
57+ $ docker pass set GH_TOKEN=123456789
58+ ` + "```" + `
59+
60+ Create a secret from STDIN:
61+
62+ ` + "```" + `console
63+ echo "my_val" | docker pass set GH_TOKEN
64+ ` + "```" + `
65+
66+ Run a container that uses the secret:
67+
68+ ` + "```" + `console
69+ $ docker run -e GH_TOKEN= -dt --name demo busybox
70+ ` + "```" + `
71+
72+ Inspect the secret from inside the container:
73+
74+ ` + "```" + `console
75+ $ docker exec demo sh -c 'echo $GH_TOKEN'
76+ 123456789
77+ ` + "```" + `
78+
79+ Explicitly assign a secret to a different environment variable:
80+
81+ ` + "```" + `console
82+ $ docker run -e GITHUB_TOKEN=se://GH_TOKEN -dt --name demo busybox
83+ ` + "```" + `
84+
85+ ### Using keychain secrets in Compose
86+
87+ Store the secrets:
88+
89+ ` + "```" + `console
90+ $ docker pass set myapp/anthropic/api-key=sk-ant-...
91+ $ docker pass set myapp/postgres/password=s3cr3t
92+ ` + "```" + `
93+
94+ ` + "```" + `yaml
95+ services:
96+ api:
97+ image: service1
98+ environment:
99+ - ANTHROPIC_API_KEY=se://myapp/anthropic/api-key
100+ - POSTGRES_PASSWORD=se://myapp/postgres/password
101+
102+ worker:
103+ image: service2
104+ command: worker
105+ environment:
106+ - ANTHROPIC_API_KEY=se://myapp/anthropic/api-key
107+
108+ db:
109+ image: postgres:17
110+ environment:
111+ - POSTGRES_PASSWORD=se://myapp/postgres/password
112+ ` + "```"
113+
50114// Root returns the root command for the docker-pass CLI plugin
51115func Root (ctx context.Context , s store.Store , info commands.VersionInfo ) * cobra.Command {
52116 cmd := & cobra.Command {
53- Use : "pass [OPTIONS] " ,
117+ Use : "pass set|get|ls|rm " ,
54118 Short : "Manage your local OS keychain secrets." ,
55119 Long : `Docker Pass is an experimental utility for managing secrets in your
56120local OS keychain. Secrets are stored using platform-specific credential
@@ -61,6 +125,7 @@ storage:
61125 - Linux: org.freedesktop.secrets API (requires DBus + gnome-keyring or kdewallet)
62126
63127Secrets can be injected into running containers at runtime using the se:// URI scheme.` ,
128+ Example : strings .TrimSpace (rootExample ),
64129 SilenceUsage : true ,
65130 TraverseChildren : true ,
66131 CompletionOptions : cobra.CompletionOptions {
0 commit comments