Pass all environment variables to swarm services

154 views Asked by At

How can I pass all common environment variables in a single domain to docker swarm services at once? Is there any third party application, docker image or service for this?

I have to give environment variables to docker swarm services one by one. It would be great if there was only one system and all its services would automatically get their environment variables from there.

1

There are 1 answers

0
ANISH SAJI  KUMAR On

You can use the docker secrets command to manage secrets for your services.

For example, to create a secret called my_secret:

$ docker secret create my_secret my_secret_value

To pass the secret to a service, you can specify it in the service's definition:

services: my_service: secrets: - my_secret

The secret will be made available to the service as an environment variable called MY_SECRET.