我正在尝试使用DockerSwarm部署多个Zookeeper(每个管理员都在自己的容器中)。
最终我想用3个Zookeeper,但现在我只是想让2个示例工作。
我现在的docker-compose.yml:
version: '3'
services:
zoo1:
image: zookeeper
restart: unless-stopped
hostname: zoo1
ports:
- 2181:2181
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=0.0.0.0:2888:3888;server.2=zoo2:2888:3888
volumes:
- ./full-stack/zoo1/data:/data
- ./full-stack/zoo1/datalog:/datalog
networks:
- kafka_network
zoo2:
image: zookeeper
restart: unless-stopped
hostname: zoo2
ports:
- 2182:2181
environment:
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=zoo1:2888:3888;server.2=0.0.0.0:2888:3888
volumes:
- ./full-stack/zoo2/data:/data
- ./full-stack/zoo2/datalog:/datalog
networks:
- kafka_network
visualizer:
image: dockersamples/visualizer:stable
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
ports:
- "8080:8080"
deploy:
placement:
constraints: [node.role == manager]
networks:
kafka_network:
external:
name: kafkaNetwork
kafkanetwork是我使用命令创建的覆盖网络
docker network create -d overlay --attachable kafkaNetwork
我发现下面的docker论坛帖子https://forums.docker.com/t/cannot-get-zookeeper-to-work-running-in-docker-using-swarm-mode/27109/3 但我的zookeeper示例无法成功运行。
1条答案
按热度按时间sxpgvts31#
解决了的。