问题描述
ERROR: yaml.parser.ParserError: while parsing a block mapping
in "././tmp/statelesscs_compose.yml", line 1, column 1
expected <block end>, but found ':'
in "././tmp/statelesscs_compose.yml", line 4, column 1
docbase installation completed
在执行以下yml文件时。能否建议我解决此问题。
while executing the below yml file.can you please suggest me how to resolve this.
示例用法:
docker-compose -f my.yml up
也让我知道有没有用于格式化yml文件的工具,以便我可以轻松修改
also let me know is there any tool for formatting yml file so that i can easily modify
my.yml:
version: '2'
services:
ubuntupgcsstateless:
image: ubuntupgstatelesscsimage
environment:
- EXTERNAL_IP=10.31.86.164
- EXTERNALDB_IP=10.31.86.165
- EXTERNALDB_ADMIN_USER=postgres
- EXTERNALDB_ADMIN_PASSWORD=password
- DOCBASENAME=DocbaseName
hostname:
"ubuntupgcsstateless"
container_name:
"ubuntupgcsstateless"
ports:
- "1689:1689"
- "1690:1690"
- "50000:50000"
- "50001:50001"
- "9080:9080"
- "9082:9082"
volumes:
- DocbaseName_data:/home/dmadmin/dctm/data
- DocbaseName_dba:/home/dmadmin/dctm/dba
- DocbaseName_share:/home/dmadmin/dctm/share
- DocbaseName_dfc:/home/dmadmin/dctm/config
- DocbaseName_xhive_storage:/home/dmadmin/dctm/xhive_storage
- DocbaseName_mdserver:/home/dmadmin/dctm/wildfly9.0.1/server/DctmServer_MethodServer
privileged: true
volumes:
DocbaseName_data:
DocbaseName_dba:
DocbaseName_share:
DocbaseName_dfc:
DocbaseName_xhive_storage:
DocbaseName_mdserver:
推荐答案
如果空格确实存在空格,则您提供的YAML不会产生错误。因此,请检查您的YAML中是否包含Tab或其他隐藏字符。
The YAML you provided does not generate an error if the spaces there are indeed spaces. So check your YAML for Tab or other hidden characters.
import ruamel.yaml
yaml_str = """\
version: '2'
services:
ubuntupgcsstateless:
image: ubuntupgstatelesscsimage
environment:
- EXTERNAL_IP=10.31.86.164
- EXTERNALDB_IP=10.31.86.165
- EXTERNALDB_ADMIN_USER=postgres
- EXTERNALDB_ADMIN_PASSWORD=password
- DOCBASENAME=DocbaseName
hostname:
"ubuntupgcsstateless"
container_name:
"ubuntupgcsstateless"
ports:
- "1689:1689"
- "1690:1690"
- "50000:50000"
- "50001:50001"
- "9080:9080"
- "9082:9082"
volumes:
- DocbaseName_data:/home/dmadmin/dctm/data
- DocbaseName_dba:/home/dmadmin/dctm/dba
- DocbaseName_share:/home/dmadmin/dctm/share
- DocbaseName_dfc:/home/dmadmin/dctm/config
- DocbaseName_xhive_storage:/home/dmadmin/dctm/xhive_storage
- DocbaseName_mdserver:/home/dmadmin/dctm/wildfly9.0.1/server/DctmServer_MethodServer
privileged: true
volumes:
DocbaseName_data:
DocbaseName_dba:
DocbaseName_share:
DocbaseName_dfc:
DocbaseName_xhive_storage:
DocbaseName_mdserver:
"""
data = ruamel.yaml.round_trip_load(yaml_str)
print(ruamel.yaml.round_trip_dump(data))
虽然根据YAML规范的要求,您应始终为映射中的键缩进相同的空格数(使用1和2的空格,我建议使用2),以及序列中的元素(再次使用1和2的空格,我建议对映射值的序列使用0。)
Although not required by the YAML specification, you should consistently indent with the same number of spaces for keys in a mapping (you use 1 and 2 spaces, I recommend two) as well as elements in a sequence (again you use 1 and 2 spaces, I recommend using 0 for sequences that are mapping values).
尝试使用 Dockerfile
和<$ c进行以下操作$ c> docker-compose :
version: '2'
services:
ubuntupgcsstateless:
image: ubuntupgstatelesscsimage
environment:
- EXTERNAL_IP=10.31.86.164
- EXTERNALDB_IP=10.31.86.165
- EXTERNALDB_ADMIN_USER=postgres
- EXTERNALDB_ADMIN_PASSWORD=password
- DOCBASENAME=DocbaseName
hostname:
"ubuntupgcsstateless"
container_name:
"ubuntupgcsstateless"
ports:
- "1689:1689"
- "1690:1690"
- "50000:50000"
- "50001:50001"
- "9080:9080"
- "9082:9082"
volumes:
- DocbaseName_data:/home/dmadmin/dctm/data
- DocbaseName_dba:/home/dmadmin/dctm/dba
- DocbaseName_share:/home/dmadmin/dctm/share
- DocbaseName_dfc:/home/dmadmin/dctm/config
- DocbaseName_xhive_storage:/home/dmadmin/dctm/xhive_storage
- DocbaseName_mdserver:/home/dmadmin/dctm/wildfly9.0.1/server/DctmServer_MethodServer
privileged: true
volumes:
DocbaseName_data:
DocbaseName_dba:
DocbaseName_share:
DocbaseName_dfc:
DocbaseName_xhive_storage:
DocbaseName_mdserver:
这篇关于yaml.parser.ParserError:解析块映射时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!