Zookeeper docker image three supported modes:
- Local (Standalone) Mode
- Pseudo-Distributed Mode
- Fully-Distributed Mode
Standalone Mode
Deoply only one zookeeper instance to single matchine.
docker-compose.yml
1 2 3 4 5 6 7 8 9 10 11 12 13
| version: '2' services: zookeeper1: container_name: zookeeper1 hostname: zk1 image: fjcanyue/zookeeper restart: always expose: - "2181" ports: - "2181:2181" environment: ZOOKEEPER_PORT: 2181
|
Pseudo-Distributed Mode
Deoply three zookeeper instances to single matchine.
docker-compose.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| version: '2' services: zookeeper1: container_name: zookeeper1 hostname: zk1 image: fjcanyue/zookeeper restart: always expose: - "2181" - "2888" - "3888" ports: - "2181:2181" environment: ZOOKEEPER_PORT: 2181 ZOOKEEPER_MYID: 1 ZOOKEEPER_NODES: server.1=zk1:2888:3888,server.2=zk2:2888:3888,server.3=zk3:2888:3888 networks: isolated_network: aliases: - zk1
zookeeper2: container_name: zookeeper2 hostname: zk2 image: fjcanyue/zookeeper restart: always expose: - "2181" - "2888" - "3888" ports: - "2182:2181" environment: ZOOKEEPER_PORT: 2181 ZOOKEEPER_MYID: 2 ZOOKEEPER_NODES: server.1=zk1:2888:3888,server.2=zk2:2888:3888,server.3=zk3:2888:3888 networks: isolated_network: aliases: - zk2
zookeeper3: container_name: zookeeper3 hostname: zk3 image: fjcanyue/zookeeper restart: always expose: - "2181" - "2888" - "3888" ports: - "2183:2181" environment: ZOOKEEPER_PORT: 2181 ZOOKEEPER_MYID: 3 ZOOKEEPER_NODES: server.1=zk1:2888:3888,server.2=zk2:2888:3888,server.3=zk3:2888:3888 networks: isolated_network: aliases: - zk3
networks: isolated_network: driver: bridge
|
Fully-Distributed Mode
Deoply three zookeeper instances to three matchines.
docker-compose.yml on matchine 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| version: '2' services: zookeeper1: container_name: zookeeper1 hostname: zk1 image: fjcanyue/zookeeper restart: always expose: - "2181" - "2888" - "3888" ports: - "2181:2181" environment: ZOOKEEPER_PORT: 2181 ZOOKEEPER_MYID: 1 ZOOKEEPER_NODES: server.1=matchine1:2888:3888,server.2=matchine2:2888:3888,server.3=matchine3:2888:3888
|
docker-compose.yml on matchine 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| zookeeper2: container_name: zookeeper2 hostname: zk2 image: fjcanyue/zookeeper restart: always expose: - "2181" - "2888" - "3888" ports: - "2181:2181" environment: ZOOKEEPER_PORT: 2181 ZOOKEEPER_MYID: 2 ZOOKEEPER_NODES: server.1=matchine1:2888:3888,server.2=matchine2:2888:3888,server.3=matchine3:2888:3888
|
docker-compose.yml on matchine 3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| zookeeper3: container_name: zookeeper3 hostname: zk3 image: fjcanyue/zookeeper restart: always expose: - "2181" - "2888" - "3888" ports: - "2181:2181" environment: ZOOKEEPER_PORT: 2181 ZOOKEEPER_MYID: 3 ZOOKEEPER_NODES: server.1=matchine1:2888:3888,server.2=matchine2:2888:3888,server.3=matchine3:2888:3888
|