Reputation: 705
Problem: the below content returns "service 'image' must be a mapping not a string." I tried using YAML Parser(http://yaml-online-parser.appspot.com/), but it returned no error.
version:
"2.0"
services:
blog:
image:
abc/defg
environment:
APPLICATION_SECRET:
82xxxxxxx
ports: -"9000:9000"
working version:
version: "2.1"
services:
blog:
image: abc/defg
environment:
APPLICATION_SECRET:
82xxx
ports:
- "9000:9000"
networks:
default:
external:
name: nat
Upvotes: 0
Views: 5970
Reputation: 76952
If you look at the Python output that you get from the online parser, you can see that you get
'ports': '-"9000:9000"'
which doesn't look like a list of port numbers.
A sequence element is indicated by a dash followed by a space, and if you input that space after the dash following ports
:
ports: - "9000:9000"
You actually do get an error, as block sequences that are values cannot start after the key, but must start on a line of their own:
ports:
- "9000:9000"
Although the element in the sequence have to be indented, the dash doesn't have to be, it just needs to be separated from the element by at least one space.
Upvotes: 1