Is there a way to remap an external secret to another name?
Say i have this secret in my docker-compose file:
DATABASE_URL_STAGING:
external: true
Can the DATABASE_URL_STAGING be renamed to DATABASE_URL inside the compose file?
Is there a way to remap an external secret to another name?
Say i have this secret in my docker-compose file:
DATABASE_URL_STAGING:
external: true
Can the DATABASE_URL_STAGING be renamed to DATABASE_URL inside the compose file?
There is currently no command to update the name of a secret. There isn't even a docker engine api endpoint for that. https://docs.docker.com/engine/api/v1.41/#operation/SecretUpdate specifically mentions "Currently, only the Labels field can be updated."
There might be ways to achieve your goal by bypassing the docker engine, but if there are, there would be a high chance that they break in a future update.
Otherwise, you can create a new secret, then make sure the old secret is not being used anymore, and use docker secret rm <secret_name> to remove it.
Alternatively, depending on what you really need, it might be enough for you to "alias" your secret within the scope of your compose file:
secrets:
DATABASE_URL:
external: true
name: DATABASE_URL_STAGING
services:
my_service:
...
secrets:
- DATABASE_URL
Your external secret name would be DATABASE_URL_STAGING, but you could use DATABASE_URL in the compose file.