validating ...\p7\compose.yaml: services.web.depends_on must be a array means depends_on was given a single name as a plain string, as in depends_on: db. Compose wants a list, even for one service. Write depends_on: and put - db on the next line.

The message names the exact key, services.web.depends_on, so the fix is on that line of the web service. The YAML itself is fine; Compose's own validation refuses the shape of the value.

The error

PS> docker compose -f compose.yaml config
validating ...\p7\compose.yaml: services.web.depends_on must be a array

The file (the long path in the message is shortened above):

name: fix10-cy-p7
services:
  web:
    image: alpine
    command: ["sleep", "1"]
    depends_on: db
  db:
    image: alpine
    command: ["sleep", "1"]

Why it happens

depends_on: db is valid YAML: a key with the string db as its value. The file passes the YAML stage and fails the next one, where Compose checks each key against the shapes it accepts. For depends_on that is a list of service names or a mapping of service names to conditions, and a lone string is neither. The message starts with validating and the file path.

Other keys fail the same way with their own wording. environment: GREETING=hello written as one string gave this, although a list of KEY=value lines would also have been accepted there:

PS> docker compose -f compose.env.yaml config
validating ...\p7\compose.env.yaml: services.web.environment must be a mapping

The fix

name: fix10-cy-p7
services:
  web:
    image: alpine
    command: ["sleep", "1"]
    depends_on:
      - db
  db:
    image: alpine
    command: ["sleep", "1"]
PS> docker compose -f compose.fixed.yaml config
...
    depends_on:
      db:
        condition: service_started
        required: true
...

With - db as a one-item list, the file validates. config prints the list in its long form, a mapping with condition: service_started and required: true. Writing that long form yourself, with only condition: service_started under db:, gave the same output in the test; that is the form to edit when you need a condition other than the default.

How it was reproduced

Docker Desktop on Windows 11, Docker Compose v5.7.0, engine 29.9.3, Windows PowerShell 5.1. A two-service compose.yaml with depends_on: db gave the message above on docker compose -f compose.yaml config with exit code 1, and a file with environment as one string gave the mapping variant; the list form and the long mapping form of depends_on each printed the model with exit code 0. No container was started. The project name fix10-cy-p7 is the test's own.

Frequently asked

What does depends_on must be a array mean in docker compose?
depends_on was written as a single string, such as depends_on: db. Compose accepts a list of service names or a mapping with conditions, not a lone string.
How do I write depends_on for one service?
As a one-item list: depends_on: on one line and - db on the next. In the test config expanded it to db with condition service_started and required true.
Why does compose say environment must be a mapping?
environment was written as one string, GREETING=hello. In the test GREETING: hello on its own line under environment validated, and config printed it back.

More decoded errors in the Fixes category. The same message for ports is covered in services.web.ports must be a array.