compose: extends not supported in version 3 schema

I’m running Docker 1.13.0-rc4 and current master (545153f117a0be523eeaaed05b2458700a9e856d) of Compose.

I tried to deploy a stack using following docker-compose.yml file:

version: "3"
services:
  base:
    image: hello-world
  extending:
    extends: base
    labels:
      - "label=test"

Got following in response:

$ 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 (docker/docker#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'

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 13
  • Comments: 31

Most upvoted comments

@ABitMoreDepth I 100% agree. Having multiple -f’s is a pain. Supporting extends in Docker is the way to go.

found this issue, for the same reason as others have already mentioned.

I’ve upgraded to docker-compose v3 to take advantage of some new docker-swarm features, but now extends is no longer supported? WHY!!

It is such a useful option for writing clean dockerfiles and managing services in different environments.

+1 for bringing this back

@arun-gupta I guess it’s because a lot of docker-compose files parsing is also now done in go in docker engine source code and it’s not have been ported from python ATM cc @dnephin right?

If yes, the question is to know if it’s planned to bring it back or no. Would be nice to also know - if it’s a deprecation - if another mecanism is planned to merge some properties from some kind of abstract services (which is the main use case of extends for everyone I guess).

The docs seem a bit misleading ATM:

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.

I really believe that with the swarm inter-compatibility, the extends key becomes more important than ever

I am working on documentation fix.

@arun-gupta welcome to how the docker dev’s roll out new features, depreciating old sensible functionality for new stuff which hasn’t been released yet. Its like a great wet fish in the face, This morning I was all like

yay finally compose 3 adds deploy so I can use it with swarm instead of loads of bash scripting.

20 seconds later

what they removed “extents”…whyyyyyy… there is no god!

Thanks @shin-. I would even be happy if docker-compose config would flatten the files. Then I could use the resulting compose file with Swarm.

Maybe something like this?

docker-compose config -f docker-compose.yml -f docker-compose.prd.yml | docker stack deploy --

That’d be acceptable for the interim…