Need Kafka and Zookeeper?

A while ago we’d created docker-compose.yml for Kafka and Zookeper.

Today I’ve noticed the problem with the old configuration – it looks like it does not work properly with Test Containers. So, I have replaced the old configuration with Confluent’s Kafka and Zookeeper:

version: '3.8'

services:

  zookeeper:
    image: confluentinc/cp-zookeeper:7.2.2
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
    ports:
      - '2181:2181'

  kafka:
    image: confluentinc/cp-kafka:7.2.2
    depends_on:
      - zookeeper
    ports:
      - '29092:29092'
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:29092,PLAINTEXT_HOST://localhost:9092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1

When connecting to Kafka, connect to: localhost:29092.

One Comment

  1. Ruslanas said:

    it is 2022, and kafka still needs zookeeper, what a shame. KIP-500 has been provided in 2019, and still seems not fully implemented 🙁

    2022-11-17
    Reply

Leave a Reply to Ruslanas Cancel reply

Your email address will not be published. Required fields are marked *