If you have several docker docker-compose yml files that you want to refactor common parts from, there is currently only one way of referencing the code:
docker-compose-common.yml folder1/docker-compose.yml folder2/docker-compose.yml
The docker-compose files inside folders 1 and 2 assume the common.yml will be specified with -f.
The problem here is that for any docker-compose command that uses folders 1 or 2, the complete set of files must be given, and must therefore be known. Eg:
cd folder1 docker-compose -f ../docker-compose-common.yml -f docker-compose.yml up docker-compose -f ../docker-compose-common.yml -f docker-compose.yml down
etc. You have to remember this every time. And if you forget one of the files, docker-compose will not complain, the command will still operate, but only on the subset of services that is in the listed files.
This is unnecessarily error-prone. If the docker-compose yml supported an instruction like “include <other-docker-compose.yml file>” and recursively resolved those whenever it performs the inclusion, we would automatically get self-documenting yml file that clearly states which other files this one depends on. Also the above would allow all -f to be dropped:
cd folder1 docker-compose up
would automatically find the local docker-compose.yml, see that it includes a yml in …, load it, and continue.