Open jamshid opened 7 years ago
Relevant Stackoverflow question: https://stackoverflow.com/questions/50919605/docker-compose-variable-substitution-interpolation-with-list-map-or-array-va
Please, implement this. Tuning networks list via orchestration of compose/swarm configs is really terrible.
how about the new version, is the new version resolved array environment variable issue ? @dustinlacewell Do you know if there have new solution about this?
In some cases, I had to use some flashy operations, just in certain situations.
extra_hosts: [
"${EXTRA_HOST_0-localhost0:127.0.0.1}", "${EXTRA_HOST_1-localhost1:127.0.0.1}",
"${EXTRA_HOST_2-localhost2:127.0.0.1}", "${EXTRA_HOST_3-localhost3:127.0.0.1}"
]
EXTRA_HOST_0=server0:10.0.0.10
EXTRA_HOST_1=server1:10.0.0.11
I wonder we could support bash array syntax
devices: ${DEVICES[*]}
about the .env file format to define an array, using DEVICES =(xxx,yyy)
could have some side effect on existing configuration, so I would suggest we require each value to be set:
DEVICES[0]="/dev/sda:/dev/sda"
DEVICES[1]="/dev/sdb:/dev/sdb"
DEVICES[2]="/dev/sdc:/dev/sdc"
we also could rely on bash append operator to distinguish arrays definition with use of parentheses in a regular value:
DEVICES+=("/dev/sda:/dev/sda" "/dev/sdb:/dev/sdb")
Not sure what the syntax would be exactly, but I would like to supply an optional and variable set of devices to an docker-compose.yml service.
Seems more flexible if the variable is a string and literally substituted, but maybe shell array variables should be used instead.
It would be great if this syntax allowed "appending" to an existing hard-coded array.
Without this feature, I can't use docker-compose directly and instead have to do unnatural things with yml substitution scripts and "docker-compose -f -".
PS: I don't know what's up with docker-compose and Swarm "services" on your roadmap. IMO Compose and the yml service definitions are a really nice way to define both simple and complicated environments.