Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ WORKDIR /opt/zookeeper

# Only checks if server is up and listening, not quorum.
# See https://zookeeper.apache.org/doc/r3.5.5/zookeeperAdmin.html#sc_zkCommands
HEALTHCHECK CMD [ $(echo ruok | nc 127.0.0.1:2181) == "imok" ] || exit 1
COPY healthcheck /healthcheck
HEALTHCHECK CMD /healthcheck

VOLUME ["/opt/zookeeper/conf", "/tmp/zookeeper"]

Expand Down
11 changes: 11 additions & 0 deletions healthcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# Read bound host and port from the config file (if any)
set -e

CFG=/opt/zookeeper/conf/zoo.cfg
if [ -e "$CFG" ]; then
H="$(awk -F= '/^clientPortAddress=/{ print $2 }' "$CFG")"
P="$(awk -F= '/^clientPort=/{ print $2 }' "$CFG")"
fi

[ "$(echo ruok | nc "${H:-127.0.0.1}" "${P:-2181}")" == "imok" ] || exit 1