docker compose 如下:
version: "3.6"services:zookeeper:image: 'bitnami/zookeeper:latest'ports:- '2181:2181'environment:- ALLOW_ANONYMOUS_LOGIN=yeskafka:image: 'bitnami/kafka:3.3.2-debian-11-r183' ports:- "9092:9092"- "29092:29092"environment:- KAFKA_BROKER_ID=1- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT- KAFKA_CFG_INTER_BROKER_LISTENER_NAME=PLAINTEXT- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181- ADVERTISED_HOST=localhosthealthcheck:test: ["CMD-SHELL", "kafka-topics.sh --bootstrap-server 127.0.0.1:9092 --list"]interval: 5sretries: 10depends_on:- zookeeper
参考地址:https://github.com/bitnami/containers/issues/43918