Error yaml: line 5: mapping values are not allowed in this context

hi every body . i try to run Persist the data Lab in " https://docs.docker.com/get-started/part5/#persist-the-data " but when i run docker stack deploy -c docker-compose.yml getstartedlab with new yaml file in docker-machine myvm1 as a manager shows this message :

[root@bah-devops new-test]# docker-machine ssh myvm1 "docker stack deploy -c docker-compose-WITH-REDIS.yaml getstartedlab "
yaml: line 5: mapping values are not allowed in this context
exit status 1
[root@bah-devops new-test]#

thankfully if help me to complete this Lab.

That particular class of error is typically a syntax error in the YAML. Since you didn’t provide a copy of your YAML, we can only guess at the issue. It can be as simple as a missing space character or “:”, the use of tabs instead of spaces, or a misaligned block.

In the section you referenced, here are the first 5 lines

version: "3"
services:
  web:
    # replace username/repo:tag with your name and image details
    image: username/repo:tag

If you have copied that file literally, the line with “image:” and everything before, are the place to look for items I’ve mentioned above, as well as missing quotation marks, colons, and incorrect whitespace.

Best of luck

1 Like

I am a beginner for the docker.Can anyone help on this.
I got the same error.
yaml: line 5: mapping values are not allowed in this context

Ill attache my yml file below.

version: “3”
services:
web:
# replace username/repo:tag with your name and image details
image: dineshdockertest/get-started:part2
deploy:
replicas: 5
resources:
limits:
cpus: “0.1”
memory: 50M
restart_policy:
condition: on-failure
ports:
- “4000:80”
networks:
- webnet
networks:
webnet:

Regards

With the whitespace stripped it’s hard to rule out that you’re simply missing spaces. I have no idea how to post valid YAML here, I used pastebin earlier. You should check out a YAML validator, such as http://www.yamllint.com/ .

2 Likes

Hi Justin,

I used that YAML validator and it resolved my problem. Now it’s working fine.

Thank you for the support.

Regards!!

1 Like

Hi

Justine Just to say thank you… i did sign up here

Thank you boy

regards