Yaml: line 2: mapping values are not allowed in this context


here is my mongodb.yaml file , i try to run it using docker-compose -f mongodb.yaml up, but its show yaml: line 2: mapping values are not allowed in this context, can anybody help me

Please format your post according this post: How to format your forum posts. The way you posted the compose file content does not allow seeing the actual used indentations. It is crucial for yaml files to use correct indentation.

1 Like

The preferred way of sharing code is sharing it directly on the forum in the post as @meyay pointed out by mentioning the “How to format” guide. If you share a file on GitHub, that can change and tomorrow nobody will understand what we were talking about so a “permalink” to a specific file in a specific commit can be shared in that case.

Now that you pushed the code to GitHub you can also see the syntax highlighting and notice the missing space after version: By the way the version is not even used by Compose v2 and Compose v1 already reached its end of life so if you are using Compose v2, you can just remove the version line.

1 Like

thank @rimelek after giving space after version: its start working fine, in future i will use correct format for posting code.