Environment variables to services from a .env file

I have a list env variables in .env file which I set across multiple CI tasks. I can do source my.env to set these. But how can I pass these when I’m using docker service images?

image: registery.com/sdc/my-image:2.5
- source my.env

I have tried setting them manually within script as, but it does not like it unless I have variables section in the task. currently i have duplicate each env variable just for this task.

Can someone please advise?

Services are started before the script is run. I’m facing a similar problem. I have to define the environment variables for the service explicitly within the job definition.

  • I know I’m replying to an old post, but hopefully this’ll help anyone who stumbles across it.
1 Like