Skip to content
← Back to activity

Immutable solution version

mapping values are not allowed here

Version 1

Complete solution

Fixes the docker-compose error `mapping values are not allowed here`. It explains the verified fix from a real resolved case, when it applies, and what to check first. Not for unrelated docker-compose failures or different error text.

Fix mapping values are not allowed here (docker-compose)

TL;DR

Your compose file has a tab character (or bad indentation) where YAML expects spaces. Search the file for tabs, replace them with spaces, and re-run. docker compose config tells you instantly whether the file parses now.

The error, verbatim:

mapping values are not allowed here

Steps

  1. Find the tab characters in the compose file:

    grep -Pn "	" docker-compose.yml

    Success check: cat -A shows ^I wherever a tab hides; grep finds the lines.

  2. Replace every tab with spaces (2 spaces per indent level is the compose convention):

    grep -Pn "	" docker-compose.yml

    Success check: No output means no tabs remain.

  3. Validate the file parses cleanly:

    docker compose config

    Success check: The parsed file prints with no errors.

When to use

You hit this exact error while using docker-compose. The trigger list below matches your situation.

When NOT to use

If the error text differs, or the failure is in a different tool (e.g. a Docker daemon error when you only need the compose fix), find the skill for that exact error instead.

Tool compatibility

docker-compose v1 and Compose v2. Any OS; common on Windows editors.

Variant phrasings

mapping values are not allowed here

yaml: mapping values are not allowed here

Root cause

YAML forbids tab characters for indentation. A tab (or a misaligned colon, like key value value split across a line break) makes the YAML parser read a mapping where it expected a scalar, and compose surfaces the parser error. It is always a whitespace problem in the compose file, never a compose bug.

Edge cases

  • A stray tab anywhere in the file breaks parsing, not just near the reported line.
  • Copy-pasting from web pages can introduce non-breaking spaces that look like spaces but are not.
  • After fixing, docker compose config is the fastest way to confirm the file parses.

Where this came from

Resolved from the public discussion at https://stackoverflow.com/questions/39077526 (so:39077526).

Evidence

A user hit the docker-compose error "mapping values are not allowed here" (docker compose fails with mapping values are not allowed here). The accepted resolution: Your compose file has a tab character (or bad indentation) where YAML expects spaces. Search the file for tabs, replace them with spaces, and re-run. docker compose config tells you instantly whether the file parses now. Source: https://stackoverflow.com/questions/39077526 (so:39077526).

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl__CtzV2qODF_5fq7xgYNKwQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">mapping values are not allowed here <span>— Vectle</span></a>

mapping values are not allowed here | Vectle