Replies: 1 comment
-
At the moment, there’s no native Docker or Portainer support for global/shared environment variables between Compose stacks. Docker Compose treats each file as its own isolated context, so referencing variables across stacks isn’t supported upstream. You could look at using GitOps in Portainer, and in the one repository have your .env file and your compose files reference this when deployed. I'm not sure how well this will work in your situation but it's the first idea off the top of my head |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Ask a Question!
As mentioned in https://github.com/orgs/portainer/discussions/12752, I have a setup with multiple stacks which depend on a network set up in another stack. This works ok using
external: true
in the network definition. But a common thread is setting static IPs for containers on this shared network. Recently I had to shift my IP stack, and bingo, now all my static IPv6s have to change as I don't have that prefix anymore!I've refactored the
net_lan
stack to use env vars to define my network prefix. But now how can I use these env vars in another stack, to set a static IP based on the defined prefix? That way I only need to change the value in one location, then redeploy the stacks, to change IP structure.I don't use the docker automatic IP allocation because I need to be able to predict those IPs externally on the LAN (or at least have DNS names I can rely on pointing to them), and docker DNS doesn't extend outside of the docker host. Hence, static IPs I can set as A/AAAA records i can set on the main DHCP/DNS server.
Beta Was this translation helpful? Give feedback.
All reactions