FG
☁️ Cloud & DevOpsDocker

When using multiple docker-compose.yml files from different directories, local paths are not followed correctly.

Freshover 3 years ago
Mar 14, 20260 views
Confidence Score75%
75%

Problem

Consider the following command, working from `~/myproj/`: `docker-compose -f docker-compose.yml -f somesubmodule/docker-compose.yml up` Suppose `somesubmodule/docker-compose.yml` contains the following [code block] `docker-compose up` fails because it will try to build `myservice` from `~/myproj/myservice/docker-compose.yml` instead of `~/myproj/myservice/somesubmodule/docker-compose.yml`. The error message is something like: `ERROR: build path ~/myproj/myservice/ either does not exist, is not accessible, or is not a valid URL.` This happened with docker-compose version 1.8.0-rc1, build 9bf6bc6, installed from Homebrew on my Mac OS X Yosemite version 10.10.5 Note that simply running `docker-compose -f somesubmodule/docker-compose.yml up` works fine, it's probably a glitch due to merging yml files and losing locality. Relative paths should be expanded before merging instead.

Error Output

error message is something like: `ERROR: build path ~/myproj/myservice/ either does not exist, is not accessible, or is not a valid URL.`

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
75% confidence100% success rate7 verificationsLast verified Mar 14, 2026

Solution: When using multiple docker-compose.yml files from different directories, local paths are not followed correctly.

Low Risk

I've found this link particularly clear when it comes to using multiple compose files. I'm not sure whether the page has been published recently or whether the behavior described matches the current implementation but it _kind of_ makes sense. Specifically: > Understanding multiple Compose files > ... > When you use multiple configuration files, you must make sure all paths in the files are rel

75

Trust Score

7 verifications

100% success
  1. 1

    I've found this link particularly clear when it comes to using multiple compose

    I've found this link particularly clear when it comes to using multiple compose files.

  2. 2

    I'm not sure whether the page has been published recently or whether the behavio

    I'm not sure whether the page has been published recently or whether the behavior described matches the current implementation but it _kind of_ makes sense.

  3. 3

    > Understanding multiple Compose files

    > ... > When you use multiple configuration files, you must make sure all paths in the files are relative to the base Compose file (the first Compose file specified with -f). This is required because override files need not be valid Compose files. Override files can contain small fragments of configuration. Tracking which fragment of a service is relative to which path is difficult and confusing, so to keep paths easier to understand, all paths must be defined relative to the base file.

  4. 4

    Although, I don't particularly agree that this should be _the only way_ of handl

    Although, I don't particularly agree that this should be _the only way_ of handling relative paths and I can try to elaborate a little bit more by providing a simple example.

Validation

Resolved in docker/compose GitHub issue #3874. Community reactions: 30 upvotes.

Verification Summary

Worked: 7
Partial: 2
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

dockerdocker-composecontainersstatus/0-triagestale