Official Repository

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

Supported tags and respective Dockerfile links

For more information about this image and its history, please see the relevant manifest file (library/zookeeper). This image is updated via pull requests to the docker-library/official-images GitHub repo.

For detailed information about the virtual/transfer sizes and individual layers of each of the above supported tags, please see the repos/zookeeper/ file in the docker-library/repo-info GitHub repo.

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.

Supported Docker versions

This image is officially supported on Docker version 1.13.1.

Support for older versions (down to 1.6) is provided on a best-effort basis.

Please see the Docker installation documentation for details on how to upgrade your Docker daemon.

User Feedback


If you have any problems with or questions about this image, please contact us through a GitHub issue. If the issue is related to a CVE, please check for a cve-tracker issue on the official-images repository first.

You can also reach many of the official image maintainers via the #docker-library IRC channel on Freenode.


You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.

Before you start to code, we recommend discussing your plans through a GitHub issue, especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.


Documentation for this image is stored in the zookeeper/ directory of the docker-library/docs GitHub repo. Be sure to familiarize yourself with the repository's file before attempting a pull request.

Docker Pull Command

Comments (3)
a month 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!

a month 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}.

2 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 ?