I am trying to deploy a zookeeper cluster using docker on differents hosts. I use the next docker-compose where I run zoo1 in host1 zoo2 in host2 and zoo3 in host3.
version: '2'
services:
zoo1:
image: 31z4/zookeeper
restart: always
ports:
- 2181:2181
- 2888:2888
- 3888:3888
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=host1-IP:2888:3888 server.2=host2-IP:2888:3888 server.3=host3-IP:2888:3888
zoo2:
image: 31z4/zookeeper
restart: always
ports:
- 2182:2181
- 2888:2888
- 3888:3888
environment:
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=host1-IP:2888:3888 server.2=host2-IP:2888:3888 server.3=host3-IP:2888:3888
zoo3:
image: 31z4/zookeeper
restart: always
ports:
- 2183:2181
- 2888:2888
- 3888:3888
environment:
ZOO_MY_ID: 3
ZOO_SERVERS: server.1=host1-IP:2888:3888 server.2=host2-IP:2888:3888 server.3=host3-IP:2888:3888
The code is added from: https://github.com/31z4/zookeeper-docker
I just try with the next docker-compose too, and adding zoo1, zoo2 and zoo3 to the /etc/hosts file:
version: '2'
services:
zoo1:
image: 31z4/zookeeper
restart: always
ports:
- 2181:2181
- 2888:2888
- 3888:3888
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo2:
image: 31z4/zookeeper
restart: always
ports:
- 2182:2181
- 2888:2888
- 3888:3888
environment:
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=zooo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo3:
image: 31z4/zookeeper
restart: always
ports:
- 2183:2181
- 2888:2888
- 3888:3888
environment:
ZOO_MY_ID: 3
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
But it is not working, if I check the status:
./bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /conf/zoo.cfg
Error contacting service. It is probably not running.