Common causes
1. An unquoted value that contains ": "
Commands, messages and titles often contain a colon followed by a space. Quote the whole value. A colon without a following space, as in nginx:1.27 or a URL, is fine unquoted.
command: echo Status: readycommand: "echo Status: ready"2. A key indented under a key that already has a value
Once image: nginx has a value on the same line, it cannot also have children. The extra indentation makes ports look like a nested mapping inside a string. Align sibling keys.
image: nginx
ports: 80image: nginx
ports: 803. A long text continued on the next line
A plain value may continue on more-indented lines, but a continuation line containing : is read as a key. Use a block scalar: > folds lines together, | keeps the line breaks.
description: Deploys the web tier
and notes: run migrations firstdescription: >
Deploys the web tier
and notes: run migrations first4. Windows paths or times after a key
Values such as C: drive or Note: 10:30 contain a colon and a space. Single quotes are the safest choice here because backslashes stay literal inside them.
backup_target: D: backups\nightlybackup_target: 'D: backups\nightly'Frequently asked questions
Why is "image: nginx:1.27" fine but "echo Status: ready" not?
Only a colon followed by a space (or the end of the line) is a key indicator. In nginx:1.27 and https://example.com the colon is followed by a non-space character, so it is part of the value.
Should I use single or double quotes?
Single quotes keep backslashes literal, and you write a single quote as two. Double quotes support escapes such as \n and \t. For plain text containing ": " either works.
Why does the line number point after the real problem?
The parser only notices the second colon when it reaches it, which may be on a continuation line. Check the key on the line above too, especially its indentation.