go-yaml load error in parser (while parsing a block collection) ... did not find expected '-' indicator means one item of a list in your Compose file does not start in the same column as the item before it. In the test the second port sat one space to the right of the first. Line every dash of the list up in one column.

The range L7.C7-L8.C8 runs from the first item of the list (line 7, column 7) to the place the parser stopped (line 8, column 8). The item at the end of the range is the one out of line.

The error

PS> docker compose -f compose.yaml config
go-yaml load error in parser (while parsing a block collection) at L7.C7-L8.C8: did not find expected '-' indicator

The file, where the second item has seven spaces before its dash and the first six:

name: fix10-cy-p3
services:
  web:
    image: alpine
    command: ["sleep", "1"]
    ports:
      - "127.0.0.1:15900:80"
       - "127.0.0.1:15901:443"

Why it happens

A block list in YAML is a run of lines that each begin with - in the same column. The first item fixes that column at 7. On line 8 the parser finds text at column 8: too far right to be the next item, and not a dash where it expected one, so it stops with the message above. The words "block collection" in the message are YAML's name for such a list.

An item that lost its dash but stayed in the same column breaks the list too, with a different message. The same file with the second item written as "127.0.0.1:15901:443" under the first gave:

PS> docker compose -f compose.nodash.yaml config
go-yaml load error in scanner (while scanning a simple key) at L8.C7-L9.C1: could not find expected ':'

That is the message a key without a colon gives, covered in could not find expected ':'. So when a list fails, check the line at the end of the range for both: the dash present, and the dash in the same column as the one above.

The fix

name: fix10-cy-p3
services:
  web:
    image: alpine
    command: ["sleep", "1"]
    ports:
      - "127.0.0.1:15900:80"
      - "127.0.0.1:15901:443"
PS> docker compose -f compose.fixed.yaml config
...
    ports:
      - mode: ingress
        host_ip: 127.0.0.1
        target: 80
        published: "15900"
        protocol: tcp
      - mode: ingress
        host_ip: 127.0.0.1
        target: 443
        published: "15901"
        protocol: tcp
...

With both dashes at six spaces the file parses, and config lists two port entries, which shows Compose read both items (the output is cut to the port list). An editor that shows whitespace, or one that draws indent guides, makes a one-space drift like this visible at once.

How it was reproduced

Docker Desktop on Windows 11, Docker Compose v5.7.0, engine 29.9.3, Windows PowerShell 5.1. A one-service compose.yaml with two port items, the second indented one space further than the first, gave the message above on docker compose -f compose.yaml config with exit code 1; with both items in the same column the same command printed the model with exit code 0. No container was started. The project name fix10-cy-p3 is the test's own.

Frequently asked

What does did not find expected '-' indicator mean in docker compose?
The YAML parser was reading a list and found a line that is not the next item: in the test, a list item indented one space further than the item above it.
What is a block collection in a YAML error?
It is a list written as lines that start with a dash. The message says the parser was inside such a list when it stopped.
How should list items be indented in compose.yaml?
Every dash of one list in the same column. In the fixed test file both port items have six spaces before the dash, and config listed both.

More decoded errors in the Fixes category. For keys of a mapping that are out of line, see did not find expected key.