Source at Github - https://github.com/brunofitas/docker-zookeeper/tree/3.4.11
The easiest way to run zookeeper is by launching a standalone instance:
docker run -d -p 2181:2181 --name zookeeper brunofitas/zookeeper:3.4.11
You can also run zookeeper with docker-compose:
version: '3.2'
services:
# Other services
# ...
zookeeper:
image: brunofitas/zookeeper:3.4.11
container_name: zookeeper
ports:
- 2181:2181
I order to start a zookeeper cluster (or assembly), each instance has to be set with an unique ID and
a reference to every zookeeper server in the cluster - SERVER_[N].
Here's an docker stack example that starts a single service of zookeeper on each node (worker01, worker02, worker03).
version: '3.2'
networks:
zookeeper_network:
external: true
services:
zookeeper_1:
image: brunofitas/zookeeper:3.4.11
hostname: zookeeper_1
deploy:
placement:
constraints:
- node.hostname == worker01
networks:
- zookeeper_network
environment:
- ID=1
- SERVER_1=zookeeper_1:2888:3888
- SERVER_2=zookeeper_2:2888:3888
- SERVER_3=zookeeper_3:2888:3888
zookeeper_2:
image: brunofitas/zookeeper:3.4.11
hostname: zookeeper_2
deploy:
placement:
constraints:
- node.hostname == worker02
networks:
- zookeeper_network
environment:
- ID=2
- SERVER_1=zookeeper_1:2888:3888
- SERVER_2=zookeeper_2:2888:3888
- SERVER_3=zookeeper_3:2888:3888
zookeeper_3:
image: brunofitas/zookeeper:3.4.11
hostname: zookeeper_3
deploy:
placement:
constraints:
- node.hostname == worker03
networks:
- zookeeper_network
environment:
- ID=3
- SERVER_1=zookeeper_1:2888:3888
- SERVER_2=zookeeper_2:2888:3888
- SERVER_3=zookeeper_3:2888:3888
Override the following variables to suit your needs:
ID - Id for this server.
default: 1
TICK_TIME - The number of milliseconds of each tick. default: 2000
INIT_LIMIT - The number of ticks that the initial synchronization phase can take. default: 10
SYNC_LIMIT - The number of ticks that can pass between sending a request and getting an acknowledgement. default: 5
DATA_DIR - The directory where the snapshot is stored. default: /var/zookeeper
CLIENT_PORT - The port at which the clients will connect. default: 2181
MAX_CLIENT_CONXNS - The maximum number of client connections. Increase this if you need to handle more clients. default: 60
AUTO_PURGE__SNAP_RETAIN_COUNT - The number of snapshots to retain in dataDir. default: 3
AUTO_PURGE__PURGE_INTERVAL - Purge task interval in hours. Set to "0" to disable auto purge feature. default: 1
SERVER_[n] - Zookeeper server. The fist port is used by followers to connect to the leader. The second one is used for leader election. example: zookeeper_1:2888:3888
Content type
Image
Digest
Size
104.8 MB
Last updated
over 8 years ago
docker pull brunofitas/zookeeper