Supported tags and respective
Where to file issues:
the Docker Community
Supported Docker versions:
the latest release (down to 1.6 on a best-effort basis)
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 zkCli.sh -server zookeeper
version: '2' services: zoo1: image: zookeeper restart: always ports: - 2181:2181 environment: ZOO_MY_ID: 1 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 zoo2: image: zookeeper restart: always ports: - 2182:2181 environment: ZOO_MY_ID: 2 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 zoo3: image: zookeeper restart: always ports: - 2183:2181 environment: 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
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
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
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.
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.
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
This variable allows you to specify a list of machines of the Zookeeper ensemble. Each entry has the form of
server.id=host:port:port. 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
Where to store data
This image is configured with volumes at
/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.
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
Step 2/15 : MAINTAINER Elisey Zanko email@example.com
---> Running in 1c58fb2d2497
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)
OK: 88 MiB in 55 packages
Removing intermediate container edf0c16fca5f
Step 4/15 : ENV ZOO_USER zookeeper ZOO_CONF_DIR /conf ZOO_DATA_DIR /data ZOO_DATA_LOG_DIR /datalog ZOO_PORT 2181 ZOO_TICK_TIME 2000 ZOO_INIT_LIMIT 5 ZOO_SYNC_LIMIT 2
---> Running in 6b0925979e24
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
Removing intermediate container 2f50d2bbfbbd
Step 6/15 : ARG GPG_KEY=C823E3E5B12AF29C67F81976F5CECB3CB5E9BD2D
---> Running in 776475126d42
Removing intermediate container 776475126d42
Step 7/15 : ARG DISTRO_NAME=zookeeper-3.4.10
---> Running in 68d04e001be4
Removing intermediate container 68d04e001be4
Step 8/15 : RUN set -x && apk add --no-cache --virtual .build-deps gnupg && wget -q "http://www.apache.org/dist/zookeeper/$DISTRO_NAME/$DISTRO_NAME.tar.gz" && wget -q "http://www.apache.org/dist/zookeeper/$DISTRO_NAME/$DISTRO_NAME.tar.gz.asc" && export GNUPGHOME="$(mktemp -d)" && gpg --keyserver ha.pool.sks-keyservers.net --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)
OK: 96 MiB in 67 packages
- wget -q http://www.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
- wget -q http://www.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz.asc
- mktemp -d
- export GNUPGHOME=/tmp/tmp.ljIIDG
- gpg --keyserver ha.pool.sks-keyservers.net --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) firstname.lastname@example.org" 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) email@example.com" [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/log4j.properties 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)
OK: 88 MiB in 55 packages
Removing intermediate container 75ef6b83d1cc
Step 9/15 : WORKDIR $DISTRO_NAME
Removing intermediate container 00776d3f68d7
Step 10/15 : VOLUME $ZOO_DATA_DIR $ZOO_DATA_LOG_DIR
---> Running in 49b29d03b2f7
Removing intermediate container 49b29d03b2f7
Step 11/15 : EXPOSE $ZOO_PORT 2888 3888
---> Running in 4987c434b12d
Removing intermediate container 4987c434b12d
Step 12/15 : ENV PATH $PATH:/$DISTRO_NAME/bin ZOOCFGDIR $ZOO_CONF_DIR
---> Running in 67c10216bfb8
Removing intermediate container 67c10216bfb8
Step 13/15 : COPY docker-entrypoint.sh /
Removing intermediate container 25a12f0a0a89
Step 14/15 : ENTRYPOINT /docker-entrypoint.sh
---> Running in 8a7160cd9ca2
Removing intermediate container 8a7160cd9ca2
Step 15/15 : CMD zkServer.sh start-foreground
---> Running in 9b35e87090a0
Removing intermediate container 9b35e87090a0
Successfully built a9e5ea8882fb
How to use 3.4.6 version of docker, can I create my own Dockerfile on top of 3.4.9 image?
Hello, I was wondering if you might be able to comment on the following forum discussion: https://forums.docker.com/t/cannot-get-zookeeper-to-work-running-in-docker-using-swarm-mode
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).
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
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 ?