go-yaml load error in scanner at L5.C12: block sequence entries are not allowed in this context means a list dash sits on the same line as its key, as in ports: - "127.0.0.1:15900:80". A dash list must start on the next line. Break the line after the colon, or write the list in brackets.

The position L5.C12 is the dash itself: line 5, column 12, right after ports: . Move everything from that dash onward to a new line, indented under the key.

The error

PS> docker compose -f compose.yaml config
go-yaml load error in scanner at L5.C12: block sequence entries are not allowed in this context

The file:

name: fix10-cy-p4
services:
  web:
    image: alpine
    ports: - "127.0.0.1:15900:80"

Why it happens

YAML has two ways to write a list. The block style puts each item on its own line after a - ; the flow style puts the whole list in brackets on one line. A block item can begin a line, but it cannot follow a key and its colon on the same line. After ports: the scanner expects a value on that line, finds - , the start of a block item, and refuses it at column 12.

One-line lists of this shape can turn up when a list is folded by hand to save space, or when a snippet from a chat or a web page loses its line breaks. The scanner fails before Compose looks at the content, so the message does not name the service or the key; the line and column are the pointer.

The fix

name: fix10-cy-p4
services:
  web:
    image: alpine
    ports:
      - "127.0.0.1:15900:80"
PS> docker compose -f compose.fixed.yaml config
name: fix10-cy-p4
services:
  web:
    image: alpine
    networks:
      default: null
    ports:
      - mode: ingress
        host_ip: 127.0.0.1
        target: 80
        published: "15900"
        protocol: tcp
...

With the item on its own line, indented under ports, the file parses and config prints the port in its long form (the output is cut after the service). If you want the list on one line, the flow style does that:

    ports: ["127.0.0.1:15900:80"]

That line parsed in the test too and gave the same port entry in config.

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 ports: - "127.0.0.1:15900:80" on one line gave the message above on docker compose -f compose.yaml config with exit code 1; the block form on two lines and the bracket form on one line each printed the model with exit code 0. No container was started. The project name fix10-cy-p4 is the test's own.

Frequently asked

What does block sequence entries are not allowed in this context mean?
A list item that starts with a dash was written on the same line as its key, such as ports: - "127.0.0.1:15900:80". In YAML a dash item must begin its own line.
Can I write compose ports on one line?
Yes, in brackets: ports: ["127.0.0.1:15900:80"] parsed in the test. A dash after the colon on the same line does not.
Where is the error in L5.C12?
Line 5, column 12. In the test that column was the dash right after ports: on the same line.

More decoded errors in the Fixes category. Ports written as one plain string with no dash, ports: "127.0.0.1:15900:80", passed the YAML scanner in the test and failed validation instead, with services.web.ports must be a array; that case has its own post, services.web.ports must be a array.