Which hostname to choose from a group of zookeepers

I am new to distributed system, and I am using docker to set up a group of zookeepers.

For example, I have three zookeepers started:

  • how do i add a topic to a running kafka container using docker commands?
  • kafka monitoring using JMX when running kafka in docker in boot2docker
  • Docker-compose running container
  • Docker Cloud Service Discovery Two Containers
  • Docker-compose with Storm 0.10.0 and Zookeeper (connection loss)
  • Kafka Docker - Difference between links and KAFKA_ADVERTISED_HOST_NAME
  • services:
      zoo1:
        image: zookeeper
        restart: always
        ports:
          - 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:
          - 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:
          - 2181
        environment:
          ZOO_MY_ID: 3
          ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
    

    For starting a kafka, I have to config its server.properties.
    In the zookeeper.connection=localhost:2181 example, what should I configure here?

    zookeeper.connection=zoo1 / zoo2 / zoo3:2181?
    

    or I should leave them three there? thanks

    [UPDATE]

    The kafka of course will be configured to be started within the same docker-compose.yml file.

    But the Dockerfile of kafka was written locally. and I think that I should modify the zookeeper.connect=... in server.properties accordingly instead of using the localhost.

  • How to install “ifconfig” command in my ubuntu docker image?
  • Error adding a node to docker swarm
  • Strange errors when running npm install on alpine linux
  • How to share data between host and containers using volumes in Docker Compose
  • Docker Networking and VLANs
  • docker-machine without TLS verification
  • One Solution collect form web for “Which hostname to choose from a group of zookeepers”

    You should put all as comma separated list:

    zookeeper.connect=zoo1:2181,zoo2:2181,zoo3:2181
    

    So if one ZK goes down brokers can connect to a replica.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.