go-yaml load error in scanner (while scanning a quoted scalar) ... found unknown escape character means a backslash inside a double-quoted YAML string is followed by a letter YAML does not know as an escape. A Windows path such as "C:\data\app" does it: \d is not an escape. Use forward slashes, single quotes, or doubled backslashes.

The position L7.C9-C12 runs from the opening quote on line 7, column 9, to the first backslash at column 12, the one that failed. Forward slashes are the simplest change.

The error

PS> docker compose -f compose.yaml config
go-yaml load error in scanner (while scanning a quoted scalar) at L7.C9-C12: found unknown escape character

The file:

name: fix10-cy-p6
services:
  web:
    image: alpine
    command: ["sleep", "1"]
    volumes:
      - "C:\data\app:/data"

Why it happens

In YAML, double quotes turn on escape sequences: \n is a new line, \t a tab, \\ one backslash. A backslash followed by a letter that is not in that set, such as the d of \data, is an error, and the scanner stops before Compose reads the file. Single-quoted strings have no escapes, so the same path in single quotes is read as written.

The worse case is a path whose backslashes happen to form valid escapes. In "C:\temp\app:/data" the \t is a tab and \a a bell character, so nothing fails. Compose printed this bind source for it:

PS> docker compose -f compose.tab.yaml config
...
      - type: bind
        source: "...\\p6\\C:\temp\app"
...

With a tab after C: in place of a backslash, Compose did not take the value as an absolute path and joined it to the project folder (the folder part is shortened above). config accepted the file with exit code 0 and showed this joined path as the bind source.

The fix

name: fix10-cy-p6
services:
  web:
    image: alpine
    command: ["sleep", "1"]
    volumes:
      - "C:/data/app:/data"
PS> docker compose -f compose.fixed.yaml config
...
    volumes:
      - type: bind
        source: C:/data/app
        target: /data
...

Forward slashes parse, and config showed source: C:/data/app. Two other forms worked in the test: single quotes, - 'C:\data\app:/data', and doubled backslashes inside double quotes, - "C:\\data\\app:/data"; for both config showed source: C:\data\app.

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 the bind mount "C:\data\app:/data" in double quotes gave the message above on docker compose -f compose.yaml config with exit code 1; the forward-slash, single-quoted and doubled-backslash files each printed the model with exit code 0, and the "C:\temp\app" file parsed with the joined path shown above. No container was started. The project name fix10-cy-p6 is the test's own.

Frequently asked

What does found unknown escape character mean in docker compose?
A double-quoted string holds a backslash followed by a letter YAML has no escape for. A Windows path like "C:\data\app" in double quotes gave it in the test.
How do I write a Windows path in docker-compose.yml?
Forward slashes, C:/data/app, worked in the test and config showed source C:/data/app. Single quotes around the backslash path, or doubled backslashes inside double quotes, gave source C:\data\app.
Why does compose config show my Windows path joined to the project folder?
A backslash path in double quotes can form valid escapes. In the test "C:\temp\app" was accepted, and config showed it joined to the project folder with \t and \a in place of the backslashes.

More decoded errors in the Fixes category. For another character that is legal in a text editor and not in YAML indentation, see the tab character post.