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 file.can时,请建议我如何解决这个问题。
使用示例:
docker-compose -f my.yml up
还让我知道是否有任何格式化yml文件的工具,以便我可以轻松修改
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:
答案 0 :(得分:7)
如果空格确实存在空格,则您提供的YAML不会生成错误。因此,请检查您的YAML是否有标签或其他隐藏字符。
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。
使用Dockerfile
和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:
答案 1 :(得分:0)
方法1:
但是如果这对您来说看起来很艰巨
方法2:
使用此验证工具后,我可以找到与“ docker-compose.yml”文件有关的问题,我有一些空格,制表符缩进问题