When docker stack deploy throws yaml: while parsing a block mapping at line X, column Y, the issue may not be there.
Run docker compose -f <file> config so it parses the config. You will probably get yaml: while parsing a block mapping at line X, column Y: line Z, column W: did not find expected key. This shows the actual fault is at line Z, column W.
Common causes at that line:
- Misaligned indentation (one space off is enough)
- Unquoted value containing : (colon-space) — URLs, log formats, etc.
- A stray tab mixed into space indentation
Pro tip: docker compose -f <file> config validates and expands the file with better error context before you ever hit deploy.