Skip to content

Extend a base service from the same file #1988

Description

@bfirsh

It is a common pattern to define a base service which you want several services to extend, but it's currently very verbose to do this:

docker-compose-base.yml

base:
  environment:
    FOO: bar

docker-compose.yml

web:
  extends:
    file: docker-compose-base.yml
    service: base
  ...
db:
  extends:
    file: docker-compose-base.yml
    service: base
  ...

It should be possible to extend an incomplete service in a single compose file. Something like this:

base:
  abstract: true
  environment:
    FOO: bar
web:
  extends:
    service: base
  ...
db:
  extends:
    service: base

Design decisions:

  • How should a service be marked as a service that shouldn't be run? (I've used "abstract" in the example above for the sake of illustration, pinched from Django's "abstract" models.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions