Skip to content

Allow an environment variable to be used for an array field (e.g. devices:) #4249

@jamshid

Description

@jamshid

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.

DEVICES=   # empty set, as a string
DEVICES=()   # or, empty set, as an array?
DEVICES='"/dev/sdb:/dev/sdb", "/dev/sdc:/dev/sdc"'   # as a string
DEVICES=("/dev/sdb:/dev/sdb" "/dev/sdc:/dev/sdc")   # or as an array?
foo:
   devices: [ ${DEVICES} ]   # not sure of the best syntax
   image: ...

It would be great if this syntax allowed "appending" to an existing hard-coded array.

foo:
   volumes: [ "/var/foo", ${EXTRA_VOLUMES} ]   # not sure of the best syntax
   image: ...

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions