Include other docker-compose files within a docker-compose file

Intro

Currently, I have the file structure as such:

internal-tools/
├── docker-compose.yml
├── AppA
│ └── docker-compose.AppA.yml
├── AppB
│ └── docker-compose.AppB.yml
└── AppC
│ └── docker-compose.AppC.yml

The purpose for this is to be able to download and run the docker-compose files, but still have the apps separated, to increase modularity.

The Problem

I’m trying to use the topmost docker-compose file to link to the other docker-compose files within the respective directories. I’ve looked at a few YAML references but none of them work because of course while the docker-compose files are written with a YAML syntax, it’s not actually YAML.

What I want to be able to do is just run docker-compose up from within the internal-tools directory and have Apps A, B, and C also run. At the moment I get the following:

ERROR: The Compose file './internal-tools/docker-compose.yml' is invalid because:
Invalid top-level property "$include". Valid top-level sections for this Compose file are: services, version, networks, volumes, and extensions starting with "x-".

You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

This is when trying to use $include to import the other docker-compose files.

I realize I could simply run docker-compose -f AppA/docker-compose.AppA.yml -f AppA/docker-compose.AppB.yml -f AppA/docker-compose.AppC.yml but I want to see if there’s a way to just do it through the docker-compose file.

i know this post are old but I will following this post and hope some one have found a
solution for it? :slight_smile:

You mean like this? https://serversforhackers.com/dockerized-app/compose-separated