当我运行:COMPOSE_PROJECT_NAME=zk_test docker-compose up
时,我得到错误提示
错误:在文件“./docker-compose. yml”中,服务必须是Map,而不是NoneType。
这是我的YML文件:
version: '2'
services:
zoo1:
image: zookeeper
restart: always
container_name: zoo1
ports:
- "2181:2181"
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo2:
image: zookeeper
restart: always
container_name: zoo2
ports:
- "2182:2181"
environment:
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo3:
image: zookeeper
restart: always
container_name: zoo3
ports:
- "2183:2181"
environment:
ZOO_MY_ID: 3
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
示例图像:
3条答案
按热度按时间cedebl8k1#
YAML依赖于缩进。这
是具有两个键的Map,这两个键都Map到
null
(即Python中的None
)。鉴于:
是嵌套在Map中的Map。关键字“services”具有与关键字
zoo1
的Map作为值(其再次具有值null
)。r1zhe5dt2#
只放一个空格。之前
mwecs4sa3#
要解决错误消息,只需将“ports:”语句放在“services:”代码块下,1或2个制表符空间就足够了。