-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Multi-document YAML files does not extend for service in same config without explicitly stating file #10984
Comments
Can you give more details on your usage of multi-document yaml here, and why you prefer this approach over multiple files? |
Hey @ndeloof 👋
As I'm fairly new to the whole multi-document YAML way to begin with, this is where I started to get confused, as the documentation currently states that it looks for the service configuration in the "current file", but as you've currently stated it, it looks inside the "same yaml document".
If the above is correct, I can close this issue and create a follow-up request in docker/docs.
I don't really have an actual preference (yet), it's more because I was curious testing the new feature. While I stated that I use multiple files currently, I initially didn't realize that changing to a multi-document way actually changes the way it works, as it will up the "base" service alongside the other services now as well, while previously with extends from another file it wouldn't up the "base" service. In hindsight this makes sense as the feature is about multi-document files after all (🤦♂️), and this gives me the opportunity to do the following: Multiple files (old way)
version: '3.9'
services:
php-base:
image: php:latest
version: '3.9'
services:
php-main:
extends:
service: php-base
file: common-services.yml
php-worker:
extends:
service: php-base
file: common-services.yml
restart: always Multi-document (new way)
version: '3.9'
services:
php-main:
image: php:latest
---
services:
php-worker:
extends:
service: php-main
file: docker-compose.yml
restart: always Personally for me these are the pros:
|
wording indeed need to be updated. Compose has not been designed with multi-document yaml file in mind, this recent addition require some updates. Still, I need to double check this specific scenario. As long as the extended service exists in same compose file EARLIER in the set of document, and as such has already been parsed, we SHOULD be able to retrieve it's definition and extend it. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description
I was trying the new multi-document YAML files feature and stumbled upon an issue regarding
extends
. Previously I've been using acommon-services.yml
and put in some services which mydocker-compose.yml
could extend from. Now using the multi-document setup, I've put those "base" services in the samedocker-compose.yml
file, removedfile: common-services.yml
from the extending services, and thought it would work.When performing any kind of docker compose command for the current project, e.g.
docker compose config
ordocker compose up
, I encounter the following error:But if I explictely specify
file: docker-compose.yml
inextend
for those services it has no problem upping them.So for now, I can workaround the issue by explictely stating the
file
to point to itself, but as the docs state that this should be optional makes me think this is a new bug (possibly not covered by new test cases for multi-document YAML files).Steps To Reproduce
Not working example
/home/<user>/myproject/docker-compose.yml
docker compose config
Working example
/home/<user>/myproject/docker-compose.yml
docker compose config
Compose Version
Docker Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: