You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ docker stack deploy --compose-file ./docker-compose.yml test
Compose file contains unsupported options:
extends: Support for `extends` is not implemented yet. Use `docker-compose config` to generate a configuration with all `extends` options resolved, and deploy from that.
I found an issue about it in Docker's repo (moby/moby#29304) and attempted to run the command given by the error message, which resulted in:
$ docker-compose config
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.extending: 'extends'
Reacted by Felix Seidel, Martin Honermeyer, João Soares, dirkschneemann, Alex, Morten Hekkvang, Richard Girges, Tzong Hao Chen, Sébastien HOUZÉ, Armand Abric and 3 more
I've been wondering, wouldn't adding compose/config/config_schema_v2.1.json#L124-L140 to config_schema_v3.0.json work? I tried doing that locally and it generated output correctly, but I guess it could be breaking other uses.
This option is not yet supported when deploying a stack in swarm mode with a (version 3) Compose file. Use docker-compose config to generate a configuration with all extends options resolved, and deploy from that.
Would it be a lot of effort to support the use of extends when using docker-compose not in swarm mode?
I use extends to manage production, development and test setups and would like to continue doing so outside of swarm mode, but eventually use docker stack deploy with the production variant. I can probably use @byrnedo's script above to achieve the latter, but I'm blocked running docker-compose up on a v3 file containing extends... :/
Note: This option is not yet supported when deploying a stack in swarm mode with a (version 3) Compose file. Use docker-compose config to generate a configuration with all extends options resolved, and deploy from that.
It reads like docker-compose config can be used to generate a v3 docker stack deploy-compatible docker-compose.yml file, but that is obviously not the case.
Reacted by Morten Hekkvang, Sébastien HOUZÉ, Jeff Kunkle and Tom Mornini
@willseward I strongly agree with you on this. docker-compose config should obviously be able to use the extends configuration keyword even when using version 3, according to the documentation.
It's a very ugly hacky solution to do what I'm forced to do right now:
$ docker-compose config | sed "s#version: '2\.1'#version: '3'#g"
EDIT: This is especially ugly since docker-compose will treat it as 2.1 version syntax, so it will certainly force developers into hacky solutions which will probably also be limited on certain version 3 features.
Maybe some people will create their own tools to, for the time being, replace docker-compose. I sure am tempted to do that.
At the end of the day, this is dependent on Docker Engine supporting the feature -as a result, I created moby/moby#31101 to track that possibility. Please voice your concerns there if this feature is important to your project!
@willseward yes should be cool & a great 1st step probably... but couldn't address a last issue (which was a very kind feature): abstract services.
I don't know if you have some but personally - and I'm not the only one - I have this kind of configs very often in some common-services.yml files (that I use like that docker-compose config -f common-services.yml -f docker-compose.yml)
So basically @shin-@vdemeester@dnephin what are recommandations for this use case?
Do you recommend to duplicate that in every service & every service env? Is there any other tricks?
Also, as I'm convinced that composition has always been greater than inheritance... and as extends wasn't very clear about doing either composition or inheritance or both... I guess that to push the discussion forward. The BC break is here so we can see it as an opportunity to make a new & clear proposal.
To me the ideal thing would be:
(Limited) Inheritance: To add a new abstract key at the root of the docker-compose file schema. This key can be use to describe abstract services. This way we either can reintroduce the extends key in 3.x schema but limited to abstract services. We can also avoid to use the same keyword to avoid confusion by naming it extends_abstract or whatever.
Composition: spread the word that composition of services should be done whith multiple docke-compose files (the multiple -f option of docker-compose).
@willseward solution is a great one, this not only solves the issue with no longer supporting extend, but it also solves the fact, you can't run docker-compose bundle on multiple docker files to deploy a docker stack.
Of course it would be alot easier for docker engine swarm mode to have better inter-compatibility with docker-compose to be able to deploy a stack spread across multiple compose files rather than having to implement a new feature to make a limited experimental feature work.
I agree that composition lead to more modularity than inheritance.
But Inheritance as kind of hierarchy backed in. And parent definition can be override or completed by child one. This was the case with extends.
Composition on the other hand does not include hierarchy, what would be the precedence rules ( or merging ) for service options that overlap ? ( Chaining -f does not look like real composition but not persisted inheritance )
The issue when chaining -f is that it is not persisted.
Whether or not docker supports extends in swarm mode is not even relevant to compose, is it?
If I have deploy statements in my configuration, compose warns me, then proceeds to ignore them when I'm using docker-compose up (which I do often when developing/testing).
Why should the above behaviour be any different if I'm using extends? Nothing would actually break from compose's perspective. Fair enough if docker-engine needs some extra logic to figure out whats going on but I don't really see why it should block composes' extends support, with the limited exception that it would be confusing to have a feature disparity.
Running development with three -f's would be a pain as well in my particular setup.
Finally, if compose is able to deal with extends support, it shouldn't be impossible to add support for that to docker-engine as well. If I had any time or experience with go I'd volunteer to have a go (EDIT: pun not intended...).
For the moment we've reverse engineered a python script to assemble a flattened compose file for use with docker-engine, and have left all our files in v2.1, however this makes it significantly more difficult to adjust deployment options as we go.
+1 "Supporting extends in Docker is the way to go"
We make intensive use of extends in our stack definitions and were very disappointed to hear about it not being supported in docker 1.13.1 and docker-compose config (when executed on a v3 compose file).
Activity
shin- commentedon Jan 10, 2017
cc @dnephin
chaosk commentedon Jan 20, 2017
I've been wondering, wouldn't adding compose/config/config_schema_v2.1.json#L124-L140 to config_schema_v3.0.json work? I tried doing that locally and it generated output correctly, but I guess it could be breaking other uses.
mhyz commentedon Jan 20, 2017
Note for others struggeling with this issue:
Regarding to the docs:
"extend" is NOT yet supported with a version 3 compose file.
https://docs.docker.com/compose/compose-file/#extends
viztastic commentedon Jan 26, 2017
Do we know which version of docker 'extends' will be supported in compose v3? Even if just Indicative?
byrnedo commentedon Jan 26, 2017
I've tried the
docker-compose configcommand and it says the same error.Resorted to perl: https://gist.github.com/byrnedo/7ac5e461ba0866299fdd94899bebdbd9
nicodmf commentedon Jan 28, 2017
+1 for supporting extend in v3
martsa1 commentedon Jan 30, 2017
Would it be a lot of effort to support the use of
extendswhen using docker-compose not in swarm mode?I use extends to manage production, development and test setups and would like to continue doing so outside of swarm mode, but eventually use
docker stack deploywith the production variant. I can probably use @byrnedo's script above to achieve the latter, but I'm blocked runningdocker-compose upon a v3 file containing extends... :/nicodmf commentedon Jan 31, 2017
This is the same for me, extends is a really usefull option, which for know cause a hole in hour workflow deployment
willseward commentedon Feb 1, 2017
The docs seem a bit misleading ATM:
It reads like
docker-compose configcan be used to generate a v3docker stack deploy-compatible docker-compose.yml file, but that is obviously not the case.artheus commentedon Feb 3, 2017
@willseward I strongly agree with you on this.
docker-compose configshould obviously be able to use the extends configuration keyword even when using version 3, according to the documentation.It's a very ugly hacky solution to do what I'm forced to do right now:
EDIT: This is especially ugly since docker-compose will treat it as 2.1 version syntax, so it will certainly force developers into hacky solutions which will probably also be limited on certain version 3 features.
Maybe some people will create their own tools to, for the time being, replace docker-compose. I sure am tempted to do that.
shouze commentedon Feb 9, 2017
@dnephin @shin- @vdemeester can I contribute to add back support of extends for v3.x?
What have to be done? I've quickly looked & I guess that this project has to be patched, but at least https://github.com/aanand/compose-file too.
7 remaining items
Electron-libre commentedon Feb 16, 2017
I am working on documentation fix.
willseward commentedon Feb 16, 2017
I really believe that with the swarm inter-compatibility, the
extendskey becomes more important than evershin- commentedon Feb 16, 2017
At the end of the day, this is dependent on Docker Engine supporting the feature -as a result, I created moby/moby#31101 to track that possibility. Please voice your concerns there if this feature is important to your project!
willseward commentedon Feb 16, 2017
Thanks @shin-. I would even be happy if
docker-compose configwould flatten the files. Then I could use the resulting compose file with Swarm.Maybe something like this?
That'd be acceptable for the interim...
shouze commentedon Feb 17, 2017
@willseward yes should be cool & a great 1st step probably... but couldn't address a last issue (which was a very kind feature): abstract services.
I don't know if you have some but personally - and I'm not the only one - I have this kind of configs very often in some
common-services.ymlfiles (that I use like thatdocker-compose config -f common-services.yml -f docker-compose.yml)So basically @shin- @vdemeester @dnephin what are recommandations for this use case?
Do you recommend to duplicate that in every service & every service env? Is there any other tricks?
shouze commentedon Feb 17, 2017
Also, as I'm convinced that composition has always been greater than inheritance... and as
extendswasn't very clear about doing either composition or inheritance or both... I guess that to push the discussion forward. The BC break is here so we can see it as an opportunity to make a new & clear proposal.To me the ideal thing would be:
abstractkey at the root of the docker-compose file schema. This key can be use to describe abstract services. This way we either can reintroduce theextendskey in 3.x schema but limited toabstractservices. We can also avoid to use the same keyword to avoid confusion by naming itextends_abstractor whatever.-foption of docker-compose).nshCore commentedon Feb 17, 2017
@willseward solution is a great one, this not only solves the issue with no longer supporting extend, but it also solves the fact, you can't run docker-compose bundle on multiple docker files to deploy a docker stack.
Of course it would be alot easier for docker engine swarm mode to have better inter-compatibility with docker-compose to be able to deploy a stack spread across multiple compose files rather than having to implement a new feature to make a limited experimental feature work.
Electron-libre commentedon Feb 17, 2017
I agree that composition lead to more modularity than inheritance.
But Inheritance as kind of hierarchy backed in. And parent definition can be override or completed by child one. This was the case with extends.
Composition on the other hand does not include hierarchy, what would be the precedence rules ( or merging ) for service options that overlap ? ( Chaining -f does not look like real composition but not persisted inheritance )
The issue when chaining -f is that it is not persisted.
martsa1 commentedon Feb 17, 2017
Whether or not docker supports extends in swarm mode is not even relevant to compose, is it?
If I have
deploystatements in my configuration, compose warns me, then proceeds to ignore them when I'm usingdocker-compose up(which I do often when developing/testing).Why should the above behaviour be any different if I'm using extends? Nothing would actually break from compose's perspective. Fair enough if
docker-engineneeds some extra logic to figure out whats going on but I don't really see why it should block composes'extendssupport, with the limited exception that it would be confusing to have a feature disparity.Running development with three
-f's would be a pain as well in my particular setup.Finally, if compose is able to deal with
extendssupport, it shouldn't be impossible to add support for that to docker-engine as well. If I had any time or experience with go I'd volunteer to have a go (EDIT: pun not intended...).For the moment we've reverse engineered a python script to assemble a flattened compose file for use with docker-engine, and have left all our files in v2.1, however this makes it significantly more difficult to adjust deployment options as we go.
willseward commentedon Feb 17, 2017
@ABitMoreDepth I 100% agree. Having multiple
-f's is a pain. Supportingextendsin Docker is the way to go.marascha commentedon Feb 19, 2017
+1 "Supporting extends in Docker is the way to go"
We make intensive use of
extendsin our stack definitions and were very disappointed to hear about it not being supported in docker 1.13.1 and docker-compose config (when executed on a v3 compose file).shin- commentedon Feb 21, 2017
Folks, as I wrote earlier, this is out of my hands at this point. Please comment on moby/moby#31101 instead.
shin- commentedon Mar 6, 2018
docker/cli#569