我们使用Docker CE(最新版本)和Docker Compose版本3。我有一个.yml文件,其中包含3个服务,但我想约束Grafana只在Swarm的主节点上运行。当我添加约束时,出现了以下错误:
``` yaml: line 32: did not find expected key ```
脚本如下:
``` yaml: line 32: did not find expected key ```
脚本如下:
version: '3'
services:
influxdb:
image: "influxdb:latest"
volumes:
- /mount/set/influxdb:/var/lib/influxdb
ports:
- "5076:5076"
networks:
- production
kapacitor:
image: "kapacitor:latest"
environment:
KAPACITOR_HOSTNAME: kapacitor
KAPACITOR_INFLUXDB_0_URLS_0: http://influxdb:5086
volumes:
- /mount/set/kapacitor:/var/lib/kapacitor
ports:
- "9092:9092"
networks:
- production
grafana:
image: "grafana/grafana:latest"
ports:
- "7000:7000"
networks:
- production
deploy:
placement:
constraints: [node.role == manager]
volumes:
- /iSCSIDisk/grafana/grafana.ini:/etc/grafana/grafana.ini
- /iSCSIDisk/grafana/lib:/var/lib/grafana
environment:
GF_SECURITY_ADMIN_PASSWORD: secretsecret
networks:
production:
external: true
我已经对脚本进行了多次检查,但无法找到错误的原因。可能是我忽略了什么,我检查了非空格等情况,没有发现任何问题,我还检查了其他有关相同错误的文章,也没有发现任何缺少括号或重复的情况。感谢您的帮助,谢谢。 :)