Official Repository

Last pushed: 13 hours ago
Short Description
Apache ZooKeeper is an open-source server which enables highly reliable distributed coordination.
Full Description

Supported tags and respective Dockerfile links

Quick reference

What is Apache Zookeeper?

Apache ZooKeeper is a software project of the Apache Software Foundation, providing an open source distributed configuration service, synchronization service, and naming registry for large distributed systems. ZooKeeper was a sub-project of Hadoop but is now a top-level project in its own right.

How to use this image

Start a Zookeeper server instance

$ docker run --name some-zookeeper --restart always -d zookeeper

This image includes EXPOSE 2181 2888 3888 (the zookeeper client port, follower port, election port respectively), so standard container linking will make it automatically available to the linked containers. Since the Zookeeper "fails fast" it's better to always restart it.

Connect to Zookeeper from an application in another Docker container

$ docker run --name some-app --link some-zookeeper:zookeeper -d application-that-uses-zookeeper

Connect to Zookeeper from the Zookeeper command line client

$ docker run -it --rm --link some-zookeeper:zookeeper zookeeper -server zookeeper

... via docker-compose

Example docker-compose.yml for zookeeper:

version: '2'
        image: zookeeper
        restart: always
            - 2181:2181
            ZOO_MY_ID: 1
            ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888

        image: zookeeper
        restart: always
            - 2182:2181
            ZOO_MY_ID: 2
            ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888

        image: zookeeper
        restart: always
            - 2183:2181
            ZOO_MY_ID: 3
            ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888

This will start Zookeeper in replicated mode. Run docker-compose up and wait for it to initialize completely. Ports 2181-2183 will be exposed.

Please be aware that setting up multiple servers on a single machine will not create any redundancy. If something were to happen which caused the machine to die, all of the zookeeper servers would be offline. Full redundancy requires that each server have its own machine. It must be a completely separate physical server. Multiple virtual machines on the same physical host are still vulnerable to the complete failure of that host.

Consider using Docker Swarm when running Zookeeper in replicated mode.


Zookeeper configuration is located in /conf. One way to change it is mounting your config file as a volume:

$ docker run --name some-zookeeper --restart always -d -v $(pwd)/zoo.cfg:/conf/zoo.cfg zookeeper

Environment variables

ZooKeeper recommended defaults are used if zoo.cfg file is not provided. They can be overridden using the following environment variables.

$ docker run -e "ZOO_INIT_LIMIT=10" --name some-zookeeper --restart always -d 31z4/zookeeper


Defaults to 2000. ZooKeeper's tickTime

The length of a single tick, which is the basic time unit used by ZooKeeper, as measured in milliseconds. It is used to regulate heartbeats, and timeouts. For example, the minimum session timeout will be two ticks


Defaults to 5. ZooKeeper's initLimit

Amount of time, in ticks (see tickTime), to allow followers to connect and sync to a leader. Increased this value as needed, if the amount of data managed by ZooKeeper is large.


Defaults to 2. ZooKeeper's syncLimit

Amount of time, in ticks (see tickTime), to allow followers to sync with ZooKeeper. If followers fall too far behind a leader, they will be dropped.

Replicated mode

Environment variables below are mandatory if you want to run Zookeeper in replicated mode.


The id must be unique within the ensemble and should have a value between 1 and 255. Do note that this variable will not have any effect if you start the container with a /data directory that already contains the myid file.


This variable allows you to specify a list of machines of the Zookeeper ensemble. Each entry has the form of Entries are separated with space. Do note that this variable will not have any effect if you start the container with a /conf directory that already contains the zoo.cfg file.

Where to store data

This image is configured with volumes at /data and /datalog to hold the Zookeeper in-memory database snapshots and the transaction log of updates to the database, respectively.

Be careful where you put the transaction log. A dedicated transaction log device is key to consistent good performance. Putting the log on a busy device will adversely affect performance.


View license information for the software contained in this image.

Docker Pull Command

Comments (6)
21 days ago

Woud be nice to see a complete docker swarm example. Could someone add a comment with that?

2 months ago

I'm sorry, my English not very well. so...
I have a question.
When I use "docker build -t zookeeper .", that's fail.
I don't know why?
I had trying reinstall Docker and use root to build, but I get fail again.
Can someone help me ? please.

Sending build context to Docker daemon 12.29 kB
Step 1/15 : FROM openjdk:8-jre-alpine
---> 319698b3b71a
Step 2/15 : MAINTAINER Elisey Zanko
---> Running in 1c58fb2d2497
---> a19c360afaa5
Removing intermediate container 1c58fb2d2497
Step 3/15 : RUN apk add --no-cache bash su-exec
---> Running in edf0c16fca5f
(1/6) Installing ncurses-terminfo-base (6.0-r7)
(2/6) Installing ncurses-terminfo (6.0-r7)
(3/6) Installing ncurses-libs (6.0-r7)
(4/6) Installing readline (6.3.008-r4)
(5/6) Installing bash (4.3.46-r5)
(6/6) Installing su-exec (0.2-r0)
Executing busybox-1.25.1-r0.trigger
OK: 88 MiB in 55 packages
---> 4985b6399e55
Removing intermediate container edf0c16fca5f
---> Running in 6b0925979e24
---> 8ec64bab4176
Removing intermediate container 6b0925979e24
Step 5/15 : RUN set -x && adduser -D "$ZOO_USER" && mkdir -p "$ZOO_DATA_LOG_DIR" "$ZOO_DATA_DIR" "$ZOO_CONF_DIR" && chown "$ZOO_USER:$ZOO_USER" "$ZOO_DATA_LOG_DIR" "$ZOO_DATA_DIR" "$ZOO_CONF_DIR"
---> Running in 2f50d2bbfbbd

  • adduser -D zookeeper
  • mkdir -p /datalog /data /conf
  • chown zookeeper:zookeeper /datalog /data /conf
    ---> 85dac7db4bd4
    Removing intermediate container 2f50d2bbfbbd
    Step 6/15 : ARG GPG_KEY=C823E3E5B12AF29C67F81976F5CECB3CB5E9BD2D
    ---> Running in 776475126d42
    ---> a3b09c87315a
    Removing intermediate container 776475126d42
    Step 7/15 : ARG DISTRO_NAME=zookeeper-3.4.10
    ---> Running in 68d04e001be4
    ---> 9fed6f5f81e3
    Removing intermediate container 68d04e001be4
    Step 8/15 : RUN set -x && apk add --no-cache --virtual .build-deps gnupg && wget -q "$DISTRO_NAME/$DISTRO_NAME.tar.gz" && wget -q "$DISTRO_NAME/$DISTRO_NAME.tar.gz.asc" && export GNUPGHOME="$(mktemp -d)" && gpg --keyserver --recv-key "$GPG_KEY" && gpg --batch --verify "$DISTRO_NAME.tar.gz.asc" "$DISTRO_NAME.tar.gz" && tar -xzf "$DISTRO_NAME.tar.gz" && mv "$DISTRO_NAME/conf/"* "$ZOO_CONF_DIR" && rm -r "$GNUPGHOME" "$DISTRO_NAME.tar.gz" "$DISTRO_NAME.tar.gz.asc" && apk del .build-deps
    ---> Running in 75ef6b83d1cc
  • apk add --no-cache --virtual .build-deps gnupg
    (1/12) Installing libgpg-error (1.24-r0)
    (2/12) Installing libassuan (2.4.3-r0)
    (3/12) Installing libcap (2.25-r1)
    (4/12) Installing pinentry (0.9.7-r0)
    (5/12) Installing libgcrypt (1.7.3-r0)
    (6/12) Installing libksba (1.3.4-r0)
    (7/12) Installing db (5.3.28-r0)
    (8/12) Installing libsasl (2.1.26-r8)
    (9/12) Installing libldap (2.4.44-r3)
    (10/12) Installing npth (1.2-r0)
    (11/12) Installing gnupg (2.1.15-r0)
    (12/12) Installing .build-deps (0)
    Executing busybox-1.25.1-r0.trigger
    OK: 96 MiB in 67 packages
  • wget -q
  • wget -q
  • mktemp -d
  • export GNUPGHOME=/tmp/tmp.ljIIDG
  • gpg --keyserver --recv-key C823E3E5B12AF29C67F81976F5CECB3CB5E9BD2D
    gpg: keybox '/tmp/tmp.ljIIDG/pubring.kbx' created
    gpg: /tmp/tmp.ljIIDG/trustdb.gpg: trustdb created
    gpg: key F5CECB3CB5E9BD2D: public key "Rakesh Radhakrishnan (CODE SIGNING KEY)" imported
    gpg: Total number processed: 1
    gpg: imported: 1
  • gpg --batch --verify zookeeper-3.4.10.tar.gz.asc zookeeper-3.4.10.tar.gz
    gpg: Signature made Thu Mar 23 11:45:03 2017 UTC
    gpg: using RSA key F5CECB3CB5E9BD2D
    gpg: Good signature from "Rakesh Radhakrishnan (CODE SIGNING KEY)" [unknown]
    gpg: WARNING: This key is not certified with a trusted signature!
    gpg: There is no indication that the signature belongs to the owner.
    Primary key fingerprint: C823 E3E5 B12A F29C 67F8 1976 F5CE CB3C B5E9 BD2D
  • tar -xzf zookeeper-3.4.10.tar.gz
  • mv zookeeper-3.4.10/conf/configuration.xsl zookeeper-3.4.10/conf/ zookeeper-3.4.10/conf/zoo_sample.cfg /conf
  • rm -r /tmp/tmp.ljIIDG zookeeper-3.4.10.tar.gz zookeeper-3.4.10.tar.gz.asc
  • apk del .build-deps
    WARNING: Ignoring APKINDEX.c51f8f92.tar.gz: No such file or directory
    WARNING: Ignoring APKINDEX.d09172fd.tar.gz: No such file or directory
    (1/12) Purging .build-deps (0)
    (2/12) Purging gnupg (2.1.15-r0)
    (3/12) Purging pinentry (0.9.7-r0)
    (4/12) Purging libksba (1.3.4-r0)
    (5/12) Purging libassuan (2.4.3-r0)
    (6/12) Purging libgcrypt (1.7.3-r0)
    (7/12) Purging libgpg-error (1.24-r0)
    (8/12) Purging libcap (2.25-r1)
    (9/12) Purging libldap (2.4.44-r3)
    (10/12) Purging libsasl (2.1.26-r8)
    (11/12) Purging db (5.3.28-r0)
    (12/12) Purging npth (1.2-r0)
    Executing busybox-1.25.1-r0.trigger
    OK: 88 MiB in 55 packages
    ---> 459e7847af38
    Removing intermediate container 75ef6b83d1cc
    Step 9/15 : WORKDIR $DISTRO_NAME
    ---> 019e5bdb36a8
    Removing intermediate container 00776d3f68d7
    ---> Running in 49b29d03b2f7
    ---> f889ba5385d0
    Removing intermediate container 49b29d03b2f7
    Step 11/15 : EXPOSE $ZOO_PORT 2888 3888
    ---> Running in 4987c434b12d
    ---> c74245a00dca
    Removing intermediate container 4987c434b12d
    ---> Running in 67c10216bfb8
    ---> ee2e3c486c5f
    Removing intermediate container 67c10216bfb8
    Step 13/15 : COPY /
    ---> 9fc0f6bef48b
    Removing intermediate container 25a12f0a0a89
    Step 14/15 : ENTRYPOINT /
    ---> Running in 8a7160cd9ca2
    ---> ba78f1ee9c63
    Removing intermediate container 8a7160cd9ca2
    Step 15/15 : CMD start-foreground
    ---> Running in 9b35e87090a0
    ---> a9e5ea8882fb
    Removing intermediate container 9b35e87090a0
    Successfully built a9e5ea8882fb
5 months ago

How to use 3.4.6 version of docker, can I create my own Dockerfile on top of 3.4.9 image?

6 months ago

Hello, I was wondering if you might be able to comment on the following forum discussion:

Essentially, I am trying to use your image to set up a zookeeper ensemble in a docker swarm created using the swarm mode of the docker daemon. Unfortunately, due to the fact that Virtual IPs are used to address docker services and the fact that zookeeper only listens for election messages bound for the resolved IP of a host on 3888, the zookeeper instances are unable to hold an election as they cannot communicate over this port (packets get dropped in the container as eth0 has a different IP than the Virtual one that is resolved by the zookeeper software).

Thank you!

7 months ago

In general it depends on your configuration. Assuming you use the compose file above and your Docker host is localhost you can figure out exposed ports by running docker-compose ps. And your connection URL will be localhost:{ZOO_PORT_1}, localhost:{ZOO_PORT_2},localhost:{ZOO_PORT_3}.

7 months ago

Hi ,

How to get the zookeeper connection string in docker mode ?
Use case , We are planning to run the zookeerper cluster in the docker mode to coordinated the SOLR database nodes, now what will be my zookeeper connection URL ?