compose-spec / compose-spec

The Compose specification

Home Page:https://compose-spec.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

include statement does not work a the top-level.

nelson-lark opened this issue · comments

File: 14-include.md

I can not write a docker compose file that looks like this, as implied by the article:

version: '3.9'

include:
  - path: my-service/my-service.yaml
    project_directory: .

I'm not really sure under what conditions the include statement does work, but definitely not at the top level of a docker-compose project.

Hey @nelson-lark
Can you open an issue in the https://github.com/docker/compose/issues repository with as much details as possible (docker compose version used, a simple reproduction case...)
FYI, you don't need to use the version attribute, it has been deprecated with the introduction of the Compose Specification.

I'll close your issue as the problem looks more a implementation problem than something missing in the specification itself.

So, for reference if other people come here via search like I did (thanks for being 'relevant', Google), @glours is correct in that version: has been deprecated and technically isn't needed any more, but if you only have one top-level section defined in compose.yml (eg, services: or include: on its own without anything else like volumes: or networks:) then the file does not parse correctly and you receive errors when attempting to start a stack. If you re-add version:, then it parses correctly even though it's not actually needed, hence why a lot of people still include it. I don't know whether this is docker-specific, or due to the go yaml library, but I suspect the latter.