I am having trouble with running my docker-compose.yml. I have retrieved a pre-made docker-compose file from a github page and customized it to my needs. When trying to parse it, it returns errors.
I am not very schooled in yaml syntax, so it is difficult for me to understand where the error stems from.
The code from the docker-compose.yml file is posted on this pastebin: https://pastebin.com/XjM2S11i
The following errors are returned when parsing:
ERROR:
while parsing a block mapping
in "<unicode string>", line 5, column 1:
version: "3.6"
^
expected <block end>, but found '<block mapping start>'
in "<unicode string>", line 149, column 3:
watchtower:
^
Can anyone help me fix the syntax/indentation? Would be much appreciated.
In your file you have (line 115):
phpmyadmin:
hostname: phpmyadmin
So the value for the key phpmyadmin
of your root level mapping is a mapping itself which starts of with a key hostname
which is indented four positions.
Then on line 149 you have:
watchtower:
container_name: watchtower
which is only indented two positions. You'll have to decide what is the parent node of watchtower
: either it is a key for the root level mapping and then it needs to be flush left or it is a key in the same mapping that hostname
is a key in and then it needs to be indented four positions. Or that there needs to be a key inserted at the root level mapping before watchtower
.
I strongly recommend always to use number of two positions indentation for both mapping values and sequence items (and that implies no offset for the sequence item indicator):
a:
b:
- 1
- 2
Your docker-compose YAML file is a hodgepodge of at least 2 and 4 position indentation for mappings and 2, 3 and 4 position indentation for sequence items.
That docker-compose hasn't complained about:
ports:
- "80:80"
- "443:443"
in your file yet is unexpected, as it is not valid YAML.
'lint'(语法检查)docker-compose.yml使用http://www.yamllint.com/ ,更正语法错误,然后重新运行Docker命令。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.