The local Docker Compose file is a plain YAML file you create and keep in your project directory, usually named compose.yaml or docker-compose.yml. It is not stored inside Docker Desktop, the Docker Engine, or a hidden system folder. When you run docker compose up, the Compose CLI reads the file from your current working directory (or the path you pass with -f), resolves relative paths against that file's location, and sends the resulting configuration to the Docker daemon.
That distinction matters more than most short guides admit. The file has two lives: a location on your filesystem that you control, and a resolved in-memory model that Docker builds at run time. Confusing the two is the root of most "where did my compose file go" problems.
The file lives in your project, not in Docker
Compose is a client-side tool. The docker compose subcommand is a plugin that runs as part of the Docker CLI on your machine. It parses YAML, interpolates environment variables, merges override files, and then makes API calls to the daemon. The daemon itself never needs to see your YAML file. It receives container, network, and volume specifications.
This architecture explains a common surprise. If you run Compose against a remote daemon through the DOCKER_HOST environment variable or a Docker context, your local file is still local. The daemon on the remote host has no copy of it. Any build: context or bind mount path in the file is interpreted relative to the machine running the CLI, then translated into API requests. Bind mounts, in particular, reference paths on the daemon host, which is why remote setups often break assumptions that hold on a laptop.
The default file name has shifted over time. Docker's documentation now recommends compose.yaml (or compose.yml) as the preferred name, with docker-compose.yml retained for backward compatibility. The legacy docker-compose binary, written in Python, used docker-compose.yml. The current Go-based plugin accepts both. If both exist in the same directory, the precedence rules decide which one wins, and that is worth verifying rather than guessing.
How Compose locates and resolves the file
When you run a Compose command, the CLI performs a search in a defined order. First, it checks for an explicit -f or --file flag. If present, that path is used and the search stops. Second, if the COMPOSE_FILE environment variable is set, its value is used, and multiple files can be separated by the OS path separator. Third, the CLI walks up from the current working directory toward the filesystem root, looking for compose.yaml, then compose.yml, then docker-compose.yaml, then docker-compose.yml.
That upward walk is the counterintuitive part. Compose does not only look in the directory where you typed the command. It climbs parent directories until it finds a match. This lets you run docker compose up from a subdirectory and still pick up the project-level file above you. The directory containing the found file becomes the project directory, and its name becomes the default project name unless overridden.
Once the file is chosen, a second resolution step happens. Relative paths inside the YAML, such as build: ./api or a bind mount like ./data:/var/lib/data, are resolved relative to the directory of the compose file, not the directory you ran the command from. This is a deliberate design choice and a frequent source of confusion. If you invoke Compose from a subfolder, the file is still anchored where it lives.
| Resolution input | What it points to | Typical pitfall |
|---|---|---|
| -f path/file.yaml | Explicit file, no search | Typos silently fall back only if the flag is omitted |
| COMPOSE_FILE env var | One or more files, OS-separated | Stale shell exports override your intent |
| Current directory | Starting point of upward search | Running from a deep subfolder finds a parent file |
| Parent directories | Upward walk to filesystem root | A stray file in $HOME can be picked up |
| File's directory | Anchor for relative paths | Build contexts resolve here, not your shell's cwd |
The search order also matters for multi-file setups. Overrides such as compose.override.yaml are automatically merged when present alongside the base file. You can disable that behavior or specify your own merge order with repeated -f flags. Later files take precedence for conflicting keys.
Quantified context: how much this actually affects you
The practical impact scales with project layout. A single-service project with one file in the repo root rarely hits resolution issues. A monorepo with a dozen services and nested compose files hits them constantly. In a typical local development setup, a Compose file might define 3 to 10 services, each with a build context, a handful of environment variables, and one or two volume mounts. Each relative path in that file is a potential mismatch if the working directory differs from the file's directory.
Compose project names default to the directory name, lowercased and sanitized. Two projects in sibling directories named app and app collide unless you set a distinct name via the top-level name: field or the -p flag. Container, network, and volume names are prefixed with that project name, so collisions show up as orphaned resources rather than errors. A 900-word explainer usually skips this; it is where real cleanup work begins.
Startup overhead is small. Parsing a few hundred lines of YAML and interpolating variables takes milliseconds on a modern laptop. The slow part is image pulls and builds, which can range from seconds for a cached image to several minutes for a cold multi-stage build. File location affects none of that timing directly, but a wrong path can trigger an unintended rebuild, which resets your inner loop.
Edge cases that break the obvious answer
Symlinked files and directories are the first trap. If your compose file is a symlink, the CLI may resolve relative paths against the symlink target's directory or the symlink's location depending on how the path was provided. The safe move is to use a real file or an absolute path via -f.
The second trap is the upward search combined with a home directory file. If you keep a compose.yaml in your home folder for experiments, running Compose from a project subfolder without its own file can silently pick up the home file. The symptom is strange: containers start, but they are not the ones you expected. Always check the resolved project directory, which Compose prints in its output at startup.
A third case involves Windows paths and WSL. File paths inside WSL use Linux semantics, but bind mounts from a Windows daemon reference Windows paths. The compose file may live in /home/user/project while the daemon expects C:\Users.... The file location is correct; the path translation is the problem. Fix it with explicit absolute paths or by running the CLI and daemon in the same environment.
A fourth case is CI. In a pipeline, the compose file is often checked out at a known path, and the working directory is set explicitly. If the pipeline runs from a different directory, relative paths break. Pinning -f to an absolute path in CI removes ambiguity.
A stray compose file in a parent directory can hijack your project without any error. Symlinked compose files can shift the anchor for relative build and mount paths. Remote daemons never receive your local file, so local paths may not exist there. Windows and WSL mixes can produce a correct file with broken mount paths. Two projects sharing a directory name collide on resource names unless renamed. A stale COMPOSE_FILE export can override your intended file silently.
Misconceptions worth correcting
The most common misconception is that Docker Desktop stores your compose file somewhere. It does not. Docker Desktop manages the daemon and a VM on macOS and Windows, and it provides the CLI, but your YAML is your artifact. Searching Docker's installation directories for it will not help.
The second is that docker compose config reads a file from the daemon. It does not. That command renders the fully resolved configuration locally, including merged overrides, interpolated variables, and normalized paths. It is the fastest way to see exactly which file was used and what it resolved to. Running it before up is a professional habit that catches path errors early.
The third is that the file must be named exactly docker-compose.yml. The modern CLI accepts both names, and the preferred name is now compose.yaml. If you maintain tooling that greps for the old name, you will miss newer projects.
The fourth is that the compose file is the source of truth at run time. Once containers are created, the daemon holds the actual configuration. Editing the YAML and running up again recreates containers only when Compose detects a change. Some changes, like environment variable values, require a recreate; others, like volume mount path edits, may not apply without a full teardown. The file is the desired state, not the live state.
Practical actions to lock down the location
Start by making the file explicit. Run docker compose config from your project root and read the output. It shows the resolved configuration and confirms which file was found. If you are unsure, add -f ./compose.yaml to every command in scripts and documentation.
Second, standardize on one name per repository. Pick compose.yaml for new projects and leave docker-compose.yml only where legacy tooling requires it. Avoid keeping both in the same directory.
Third, keep the file at the repository root and run commands from there. This makes the anchor and the working directory identical, eliminating the most common relative-path mismatch. If you must run from a subfolder, use an absolute -f path.
Fourth, set the project name explicitly with a top-level name: field for any project that might coexist with a sibling of the same directory name. This prevents resource collisions during cleanup.
Fifth, audit your environment. Check echo $COMPOSE_FILE and docker context show before debugging a strange startup. A stale export or an unexpected remote context explains many confusing failures.
Sixth, in CI, pass -f with an absolute path and set the working directory explicitly. Do not rely on the upward search in a pipeline.
Limitations and where the answer stops
This explanation covers the standard Docker Compose plugin on a local daemon. It does not cover third-party orchestrators, Kubernetes-based tooling, or cloud build services that may inject their own compose handling. Exact precedence rules and default file names can change across Compose versions, so verify against the documentation for the version you run. Compose behavior on remote daemons, rootless setups, and containerized CI runners has additional wrinkles not fully addressed here. The file location itself is simple; the resolution around it is where the depth lives, and that is worth testing in your own environment rather than assuming.