Public | Automated Build

Last pushed: 2 years ago
Short Description
Small (242 M) Zookeeper v3.4.7 image, that also supports CoreOS through Weave or SkyDNS
Full Description

I use Zookeeper on CoreOS, together with skyDNS or Weave for service discovery.
You can deduce from the snippet below, how to use this image on other Docker scenarios.

I recommend that you take a look at zoo.cfg, and possibly replace it using docker directory mapping (-v). The current config assumes 3 zookeepers, zoo1-zoo3, with standard ports. SkyDNS / weave take care of the rest.

$bridge_ip - because I run SkyDNS / weave on every docker host, and it binds to the docker bridge net. This is not mandatory of course

For use with SkyDNS:

Environment="CONTAINER_NAME=zoo%i"

ExecStart=/bin/bash -c  ' \
  bridge_ip="$(ifconfig docker0 | grep \'inet \' | awk \'{ print $2}\')" && \
  /usr/bin/docker run \
  --name=${CONTAINER_NAME} \
  --hostname ${CONTAINER_NAME}.multicloud.local \
  -e ZOOKEEPER_ID=%i \
  -p 2888:2888 -p 3888:3888 -p 2181:2181 \
  --dns=$bridge_ip \
  --dns-search multicloud.local \
  -e "SERVICE_2888_NAME=${CONTAINER_NAME}" \
  -e "SERVICE_3888_NAME=${CONTAINER_NAME}" \
  -e "SERVICE_2181_NAME=${CONTAINER_NAME}" \ 
  yaronr\zookeeper:latest '

For use with Weave:

ExecStart=/bin/bash -c  ' \
  bridge_ip="$(ifconfig docker0 | grep \'inet \' | awk \'{ print $2}\')" && \
  /usr/bin/docker run \
  --name=${CONTAINER_NAME} \
  --hostname=${CONTAINER_NAME}.weave.local \
  -e ZOOKEEPER_ID=%i \
  --rm \
  -p 2888:2888 -p 3888:3888 -p 2181 \
  --dns=$bridge_ip \
  --dns-search=weave.local \
  ${IMAGE_NAME}:latest '

Node: With Weave, you also need a sidekick unit to do 'weave attach' and assign the container created by this unit, an IP and a DNS entry in weave. I'll post my approach on my blog at multicloud.io in the coming days.

Note there's a small setting at the end of the dockerfile, that tells the resolver to ignore /etc/hosts. This is critical (and very useful in many scenarios)

Docker Pull Command
Owner
yaronr
Source Repository

Comments (0)