docker-compose YAML errors: "mapping values are not allowed", ports read as numbers
Last reviewed 2026-09-19
docker-compose files are YAML, which is strict about indentation and has a well-known trap: an unquoted mapping such as 22:22 can be read by YAML 1.1 parsers as a base-60 number instead of a port pair. Tabs are not allowed for indentation at all.
Messages you might see
- “yaml: line 12: mapping values are not allowed in this context”
- “found character that cannot start any token (tabs)”
- “services.web.ports contains an invalid type / port mapping 22:22 read as a number”
Why it happens
- Tab characters or mixed indentation widths.
- Port mappings written without quotes.
- A service missing both an image and a build, or a misspelled key.
- Duplicate service names, where the later one silently wins.
Try this first (free, no tool needed)
- Run `docker compose config` to validate and print the resolved file.
- Quote port mappings: "22:22".
- Turn on "show whitespace" in your editor and replace tabs with spaces.
If that didn't work
These tools run in your browser. Your file is read and repaired on your own device and is never uploaded.
Broken Docker Compose Fixer
Repairs YAML indentation and tabs, quotes port mappings like 22:22 that YAML would read as a number, and flags misspelled service keys, duplicate service names and services with neither an image nor a build. It cannot check that your images or settings are right.
Open Broken Docker Compose FixerCommon questions
Does it start my containers?
No, it only repairs and flags problems in the file. Use docker compose config to validate the final result.
Is my file uploaded anywhere?
No. The tool runs as a program inside your own browser, so the file is read and repaired on your device and never sent to a server.