patternModerate
docker-compose.yml - make network name configurable via environment variable
Viewed 0 times
configurabledockermakeenvironmentnamecomposeviaymlvariablenetwork
Problem
I have a docker compose file with env variables for stage specific configurations. As long as env variables are used in values in docker-compose.yml everything is fine, but the problem is with the network name, since it's specified in the tag.
Any chance to get the network name
networks:
mynetwork.${STAGE_NAME}:
driver: bridge
ipam:
driver: default
config:
- subnet: ${STAGE_NETWORK_PREFIX}.0/24Any chance to get the network name
mynetwork.${STAGE_NAME} configurable from outside?Solution
It is possible via network name:
where mynetwork - name "inside" stack
${STAGE_NAME} -name for other stacks/services/containers
See comment from docker capitan https://github.com/moby/moby/issues/40819#issuecomment-618726892
networks:
mynetwork:
name: ${STAGE_NAME}where mynetwork - name "inside" stack
${STAGE_NAME} -name for other stacks/services/containers
See comment from docker capitan https://github.com/moby/moby/issues/40819#issuecomment-618726892
Code Snippets
networks:
mynetwork:
name: ${STAGE_NAME}Context
StackExchange DevOps Q#6317, answer score: 13
Revisions (0)
No revisions yet.