I want to add a volume to my service, but only if the final user gave a folder for it. Otherwise, no volume should be mounted, for the already-prepared image has valid data in a
Nothing like this currently exists. Options to implement this that I can come up with include:
Make lots of compose file pieces, and merge together the parts you need to build up the final file.
Dynamically generate your compose file. Something like jsonnet may be a good starting point.
Skip compose, and just dynamically generate your docker run
command. This starts to lack portability but some use cases are just easier to script yourself.
Submit a PR to the compose and docker/cli github repos to extend the compose functionality. Doing this with a golang template syntax would make the most sense to me.