Swarm secrets keep sensitive strings out of service environment variables and image layers. A secret is created on a manager, distributed through the encrypted Swarm control plane, and mounted into only the service tasks that have been granted access.
Secrets appear inside Linux service tasks under /run/secrets unless a custom target is specified. Docker does not allow removing a secret while a running service still uses it, so rotation normally means adding a new secret, updating consumers, and then removing the old secret.
Use versioned secret names rather than overwriting meaning in place. A name such as app_password_v2 makes the active value clear during rollout, rollback, and evidence review without exposing the secret contents.
Related: How to initialize Docker Swarm
Related: How to deploy a Docker Swarm service
Tool: Secrets Rotation Planner
$ printf '%s' "$APP_PASSWORD" | docker secret create app_password_v1 - q9m2d0x1n3ab
Do not echo real secret values into saved transcripts or shared terminal logs.
$ docker secret ls ID NAME DRIVER CREATED q9m2d0x1n3ab app_password_v1 5 seconds ago
$ docker service create --name app --secret source=app_password_v1,target=app_password registry.example.com/team/app:1.0 x6b2q8q2eycg
$ docker service ps app ID NAME IMAGE CURRENT STATE r4v8n1t9f6ab app.1 registry.example.com/team/app:1.0 Running 20 seconds ago
$ printf '%s' "$APP_PASSWORD_V2" | docker secret create app_password_v2 - p1n8m5x4a2cd
$ docker service update --secret-add source=app_password_v2,target=app_password --secret-rm app_password_v1 app app
$ docker secret rm app_password_v1 app_password_v1