empty compose file — Compose found the file but it holds nothing to read: in this test once as a 0-byte compose.yaml and once as a file of comment lines only. Put at least a services: section with one service in it and the project starts.

Check that you saved the editor buffer and that you are in the folder you think you are in: the message means a file was found, so it is the content, not the name, that is missing.

The error

PS> docker compose -p fix9-cmp-c9 up -d
empty compose file

The command exited with code 1. docker compose -p fix9-cmp-c9 config on the same 0-byte file printed the same line with the same exit code. A file that held only comments gave the same result:

# services go here
# web: alpine
PS> docker compose -p fix9-cmp-c9 up -d
empty compose file

Why it happens

In YAML a comment line carries no data, and in this test a file of comments was treated exactly like a file with nothing in it. In both cases Compose had a file name, compose.yaml in the current folder, and no document inside it, and it stopped before creating a network or a container. The project name was passed with -p here because an empty file has no name: key to supply one.

The message differs from the one for a missing file. Run in a folder with no Compose file at all, the same command printed another line:

PS> docker compose -p fix9-cmp-c9 up -d
no configuration file provided: not found

So empty compose file tells you the file name was right and the content is what is missing; the other message is covered in the post linked below.

The fix

name: fix9-cmp-c9
services:
  web:
    image: alpine
    command: ["sleep", "300"]
PS> docker compose up -d
 Network fix9-cmp-c9_default Creating
...
 Container fix9-cmp-c9-web-1 Started
PS> docker compose ps
NAME                IMAGE     COMMAND       SERVICE   CREATED        STATUS                  PORTS
fix9-cmp-c9-web-1   alpine    "sleep 300"   web       1 second ago   Up Less than a second

With a service in the file the project started, under the name from the name: key.

How it was reproduced

A 0-byte compose.yaml, then one holding two comment lines, run with docker compose -p fix9-cmp-c9 up -d and config from Windows PowerShell 5.1 on Docker Engine 29.9.3 and Docker Compose v5.7.0 (Docker Desktop on Windows 11); the fix was a one-service alpine file. The project name carries this test's fix9-cmp- prefix and was removed with docker compose down -v.

Frequently asked

What does 'empty compose file' mean in Docker Compose?
Compose found a compose.yaml but it holds nothing to read. In this test a 0-byte file and a file of comment lines only both gave the message and exit code 1.
Does a docker-compose.yml with only comments count as empty?
Yes. A file with two comment lines and nothing else printed empty compose file, the same as a 0-byte file.
How do I fix empty compose file?
Save a services: section with at least one service into the file, then run docker compose up -d again. The one-service file in this test started normally.

More decoded errors in the Fixes category. When there is no Compose file at all, see Docker Compose: no configuration file provided.