I have a lot of services, which use the same basic configuration in docker-compose. Actually most of the configuration is the same, with some minor tweaks.
I have seen that it is somehow possible to inherit values in YAML. Can I use this in docker-compose to define a "default-service" and use this all over in the other services for e.g. docker-compose run
? How would I do this?
No, you cannot do that using YAML. The only inheritance like feature in YAML is the Merge Key Language Independent Type and that only works withing one YAML document, not between multiple documents in the same YAML file (separated by ---
) and certainly not between different YAML files.
However docker-compose
reads docker-compose.yml
and if available docker-compose.override.yml
, where the values in the second file (if available) override the ones in the first. Combined with the -f
option to specify an input YAML file for docker-compose
you can use a shared base file with different overrides.
This is a feature of docker-compose
and is done on the data loaded from the YAML files, not by combining the YAML files and then loading them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With