Building ZooKeeper and Elasticsearch images

To build ZooKeeper and Elasticsearch images


  1. Create the following file:

    zookeeper_elasticsearch/docker-compose.yml


    version: '2.4'
    services:
      zookeeper:
        image: zookeeper:3.9.4
        container_name: zookeeper
        mem_limit: 2g
        environment:
          - ZOO_4LW_COMMANDS_WHITELIST=ruok
        healthcheck:
          test: ["CMD-SHELL", "echo ruok | nc localhost 2181 | grep imok"]
          interval: 5s
          timeout: 10s
          retries: 3
        networks:
          - twc-net
    
      ##Below zoonavigator Section is optional###
      zoonavigator:
        image: elkozmon/zoonavigator:2.0.0
        container_name: zoonavigator
        ports:
          - "9000:9000"
        environment:
          - "CONNECTION_MYZK_CONN=zookeeper:2181"
          - "CONNECTION_LOCAL_CONN=localhost:2181"
          - "AUTO_CONNECT_CONNECTION_ID=MYZK"
        depends_on:
          zookeeper:
            condition: service_healthy
        networks:
          - twc-net
    
      elasticsearch:
        image: elasticsearch:7.16.2
        container_name: elasticsearch
        mem_limit: 4g
        ports:
          - "9200:9200"
        environment:
          - discovery.type=single-node
          - cluster.routing.allocation.disk.threshold_enabled=false
          - "ES_JAVA_OPTS=-Xms2g -Xmx2g"
        healthcheck:
          test: ["CMD", "nc", "-z", "-w2", "localhost", "9200"]
          interval: 5s
          timeout: 5s
          retries: 60
        networks:
          - twc-net
    
    networks:
      twc-net:
        external: true
    SHELL

  2. Build the image by running the following command:
    cd /twc/zookeeper_elasticsearch;
    docker compose build --no-cache
    SHELL


  3. Start the services by running the following command:
    docker compose up -d 
    SHELL