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:

  • kafka on kubernetes cannot produce/consume topics (ClosedChannelException, ErrorLoggingCallback)
  • Configuring Kafka to accept clients both from inside and outside docker
  • Kafka Docker network_mode
  • Why is the Kafka distributed connector dying when the node I created it on is killed?
  • Docker-ized Consul, Zookeeper and Kafka in Amazon-ECS
  • Kafka log directories in Docker
  • 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.

  • Docker Container DISALLOW/DISABLE communication between containers
  • How to run a simple main method and copy the file it generated using docker
  • What does it mean for a Docker environment variable to not have a name?
  • How can I ssh into “Web App On Linux” docker container on Azure?
  • lsmod returns empty output on Jelastic
  • Docker download layers sequentially
  • 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.