Skip to content

docs: correct extends path resolution guidance - #26506

Open
Duo-ee wants to merge 1 commit into
docker:mainfrom
Duo-ee:fix/issue-26501-extends-relative-paths
Open

Duo-ee wants to merge 1 commit into
docker:mainfrom
Duo-ee:fix/issue-26501-extends-relative-paths

Conversation

@Duo-ee

@Duo-ee Duo-ee commented Oct 31, 2026

Copy link
Copy Markdown

Description

The page opens with an [!IMPORTANT] block stating that "all paths must be
defined relative to the base file", which contradicts the ## Relative paths
section further down the same page. #26501
reports the contradiction and asks which one is right.

The ## Relative paths section is right. The file path of an extends
attribute is resolved relative to the main Compose file, while relative paths
declared by the service being extended are resolved relative to the Compose file
that declares them. The example on that page already shows the outcome
(env_file: ./container.env inside commons/compose.yaml becomes
../commons/container.env).

This change keeps the section, and replaces the incorrect warning with a note
that states the actual behavior. Deleting the warning outright was the first
option in the issue, but the note also carries the part that is true: file
itself is relative to the main Compose file.

Evidence from the Compose specification and compose-go v2.16.2
  • The Compose specification, 05-services.md under "Finding referenced
    service": a relative file path "is considered as relative to the location of
    the main Compose file".
  • compose-go v2.16.2, the version pinned by docker/compose's go.mod:
    • loader/extends.go loads the referenced file with ResolvePaths = false
      and a comment saying "we do relative path resolution after file has been
      loaded", then calls paths.ResolveRelativePaths(source, relworkingdir, remotes).
    • relworkingdir is loader.Dir(refPath), the directory of the referenced
      file, not the directory of the main Compose file.
    • paths/resolve.go joins each relative path (services.*.env_file.*.path,
      services.*.volumes.*, services.*.build.context, and so on) onto that
      directory.
    • services.*.extends.file has its own resolver, so a nested extends.file
      is resolved against the file that declares it.
  • Merging several files with -f is the case where paths resolve against the
    first file, which merge.md documents. The warning here applied that rule to
    extends.

Verification

  • npx --no-install rumdl fmt and npx --no-install rumdl check on the
    changed file: no issues.
  • vale with the repository configuration on the changed file: 0 errors, 0
    warnings and 0 suggestions. The i.e. in the old wording is gone with the
    rewrite.
  • Docker isn't available in this environment, so docker buildx bake validate
    wasn't run locally.

Related issues or tickets

Closes #26501

Reviews

  • Technical review
  • Editorial review
  • Product review

Generated by DeepSeek Harness, a coding agent. It drafted the change and this
description.

The page claimed that every path must be written relative to the base Compose
file, which contradicts the Relative paths section on the same page.

A service pulled in with extends keeps the relative paths it declares, resolved
against the file that declares them. Replace the warning with a note that states
the actual behavior and points to the example.
@Duo-ee
Duo-ee requested a review from aevesdocker as a code owner October 31, 2026 14:25
@netlify

netlify Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit 870de43
🔍 Latest deploy log https://app.netlify.com/projects/docsdocker/deploys/6ae5fa726e2143ab58e034d1
😎 Deploy Preview https://deploy-preview-26506--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the area/compose Relates to docker-compose.yml spec or docker-compose binary label Oct 31, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/compose Relates to docker-compose.yml spec or docker-compose binary

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confusing and contradictory information about paths resolving in extend

1 participant