open ...\db\compose.yaml: The system cannot find the path specified. — the
include: list of your Compose file names a file that is not there, measured
from the folder of the main file. Fix the path in include: or create the
file, and the project loads.
The message prints the full path Compose tried to open, so compare it with where the included file really is. "Path specified" came from a missing folder; a folder that exists with the file name spelled differently gave "file specified" instead.
The error
PS> docker compose -p fix10-cs-ph config
open C:\...\ph\db\compose.yaml: The system cannot find the path specified.
The command exited with code 1, and docker compose -p fix10-cs-ph up printed
the same line and started nothing. The path to the test folder is shortened; nothing else
in the line was changed. The file:
include:
- ./db/compose.yaml
services:
web:
image: alpine
command: ["echo", "hello"]
Why it happens
include: pulls the services of other Compose files into this project, and
here Compose stopped on the missing one before it created a network or a container. The
relative path ./db/compose.yaml was resolved against the folder of the main
file, ...\ph\, and in this test there was no db folder there at
all, and the line ended with The system cannot find the path specified.
A second test had the folder but a different extension: the db folder held
compose.yaml and the include line said compose.yml.
PS> cmd /c dir /b db
compose.yaml
PS> docker compose -p fix10-cs-pj config
open C:\...\pj\db\compose.yml: The system cannot find the file specified.
Both cases are fixed the same way; the last words only tell you whether the folder or the file was missing.
The fix
The included file in place, and the include line spelled exactly like it:
include:
- ./db/compose.yaml
services:
web:
image: alpine
command: ["echo", "web started"]
depends_on:
- db
services:
db:
image: alpine
command: ["echo", "db started"]
PS> docker compose -p fix10-cs-pk up
...
Attaching to db-1, web-1
Container fix10-cs-pk-db-1 Starting
db-1 | db started
Container fix10-cs-pk-db-1 Started
Container fix10-cs-pk-web-1 Starting
...
web-1 | web started
...
The second block is db\compose.yaml. With it found, the db
service from the included file joined the project, and web, which depends on
it, started after it. A depends_on entry can therefore name a service that is
defined only in an included file.
How it was reproduced
A main compose.yaml with one alpine service and an
include: of ./db/compose.yaml, checked with
docker compose config and up from Windows PowerShell 5.1 with no
db folder; then a second main file whose web service ran
echo web started and had depends_on: db, with an include line
that said compose.yml next to an existing db\compose.yaml
(checked with config); then that second file with the include line
corrected, started with
docker compose up. Docker Compose v5.7.0, Docker Engine 29.9.3, Docker Desktop 4.99.0
on Windows (version 10.0.26300). The project names with fix10-cs- are this test's own; the
started project was removed with docker compose down -v.
Frequently asked
- Why does docker compose include say 'The system cannot find the path specified'?
- A file listed under include: is not where the path says. In this test the db folder named in ./db/compose.yaml did not exist next to the main compose file.
- Is the include path relative to the main compose file?
- In this test it was: ./db/compose.yaml was looked up in the folder of the main compose.yaml, and the error printed that full path.
- What is the difference between 'path specified' and 'file specified' in this error?
- path specified came from a missing folder. file specified came from an existing folder where the named file was missing, here compose.yml next to a compose.yaml.
More decoded errors in the Fixes category. When the main file itself is missing, see Docker Compose: no configuration file provided, not found.