Apache Kafka Docker Compose Snippet

Updated: May 4, 2024

Snippet

docker-compose.yml
version: '3'
services:
  zookeeper:
    image: bitnami/zookeeper
    restart: unless-stopped
    environment:
      ZOO_ENABLE_AUTH: yes
      ZOO_CLIENT_USER: "zookeper"
      ZOO_CLIENT_PASSWORD: "password"
    ulimits:
      nofile:
        soft: 65536
        hard: 65536
    container_name: zookeeper
    ports:
      - "2181:2181"
    networks:
      - kafka-net
  kafka:
    image: bitnami/kafka
    restart: unless-stopped
    environment:
      KAFKA_CLIENT_USERS: "zookeeper"
      KAFKA_CLIENT_PASSWORDS: "password"
    ulimits:
      nofile:
        soft: 65536
        hard: 65536
    container_name: kafka
    ports:
      - "9092:9092"
      - "9093:9093"
    environment:
      # Change the server-ip to your server IP and connect your application through that IP when you develop the app in the development environment.
      # If the application is deployed in the same docker network, you can use kafka:9092 instead of server-ip:port since it's in the same network.
      KAFKA_ADVERTISED_LISTENERS: INSIDE://kafka:9092, OUTSIDE://server-ip:9093
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT, OUTSIDE:PLAINTEXT
      KAFKA_LISTENERS: INSIDE://0.0.0.0:9092, OUTSIDE://0.0.0.0:9093
      KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_ZOOKEEPER_USER: "zookeper"
      ZOO_CLIENT_PASSWORD: "password"
      KAFKA_CREATE_TOPICS: "minio-file-event-broadcast:1:1"
      CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: "1"
      CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: "1"
      CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: "1"
    networks:
      - kafka-net
networks:
  kafka-net:
    driver: bridge