I have this docker-compose configuration:
kafka:
image: confluentinc/cp-kafka:latest
container_name: 'virl-kafka'
restart: always
ports:
- "9092:9092"
environment:
KAFKA_KRAFT_MODE: "true"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT
KAFKA_LISTENERS: INTERNAL://0.0.0.0:9092
KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka:9092
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false" # Optional, set to true if you want auto-creation of topics
KAFKA_DELETE_TOPIC_ENABLE: "false" # Optional, set to true if you want to allow topic deletion
and when kafka starts up it says:
virl-kafka | ===> User
virl-kafka | uid=1000(appuser) gid=1000(appuser) groups=1000(appuser)
virl-kafka | ===> Configuring ...
virl-kafka | Running in Zookeeper mode...
virl-kafka | KAFKA_ZOOKEEPER_CONNECT is required.
virl-kafka | Command [/usr/local/bin/dub ensure KAFKA_ZOOKEEPER_CONNECT] FAILED !
Why is still trying to use Zookeeper?
I took a look at the configure file that runs when starting up this docker image. This will have some clues for what you need for KRAFT mode I guess. I suppose you need to take a look at KAFKA_PROCESS_ROLES.
https://github.com/confluentinc/kafka-images/blob/master/kafka/include/etc/confluent/docker/configure
Here is some more documentation https://docs.confluent.io/platform/current/installation/docker/config-reference.html#required-ak-configurations-for-kraft-mode