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 in Kubernetes Cluster- How to publish/consume messages from outside of Kubernetes Cluster
  • confluentinc kafka-zookeeper docker setup not working
  • Fig kafka hostPort mapping
  • Kafka Docker network_mode
  • Spark hangs on authentication with a Docker Mesos cluster
  • Writing to Kafka running in Docker from Python fails
  • 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 pass docker run flags via kubernetes pod
  • Failed to run service inside docker container
  • Docker Compose - Share named volume between multiple containers
  • babel/register not running on server
  • Using Docker with Sensu
  • Docker copy container volume files to host on first run
  • 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.