docker-compose.yml 显示yaml: line 1: mapping values are not allowed in this contextd

原因有可能是yml 文件格式不对,中文文档的演示代码格式有有问题的,因为在每个属性设置参数的时候 没有先用空格。

如下图:

docker-compose.yml 显示yaml: line 1: mapping values are not allowed in this contextd

解决方法 有两种。

1 ,直接修改 每个属性如设置值的时候  属性 冒号(:)后面 要加上隔空隔开,然后再写值。

2,官方文档英文版的是没有问题的,也可以直接copy 英文文档的docker-compose.yml的内容。

以上就可以解决初学者,运docker-compose.yml 会出现 line 1: mapping values are not allowed in this contextd 的问题。