These images are intended to be configuration-compatible with the confluentinc/cp-zookeeper and confluentinc/cp-kafka images; however, unlike those images, these are built as multi-architecture images for both amd64 and arm64 in order to be compatible with Mac OS on M1 Apple Silicon and the usual x86 hardware.
This image is primarily intended to support itzg/kafka while KRaft support is being finalized.
Any of the configuration parameters can be set by translating the property name from camelCase to SCREAMING_SNAKE_CASE and prefixing with "ZOOKEEPER_", such as ZOOKEEPER_CLIENT_PORT
.
The following variables are pre-declared:
ZOOKEEPER_CLIENT_PORT
= 2181ZOOKEEPER_DATA_DIR
= /var/lib/zookeeper/dataZOOKEEPER_TICK_TIME
= 1000SERVER_JVMFLAGS
= -Xmx256m
2181
/var/lib/zookeeper/data
The image comes with a health check script, /init/healthcheck
, that is pre-configured for non-Kubernetes environments.
Any of the broker configuration properties can be set by translating the property name from dot-delimited to SCREAMING_SNAKE_CASE with a prefix of KAFKA_
.
The following variables are pre-declared:
KAFKA_ZOOKEEPER_CONNECT
= zk:2181KAFKA_BROKER_ID
= 0KAFKA_LOG_DIRS
= /var/lib/kafka/dataKAFKA_ADVERTISED_LISTENERS
= PLAINTEXT://localhost:9092,BROKER://${HOSTNAME}:9093KAFKA_LISTENERS
= PLAINTEXT://0.0.0.0:9092,BROKER://0.0.0.0:9093KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
= BROKER:PLAINTEXT,PLAINTEXT:PLAINTEXTKAFKA_INTER_BROKER_LISTENER_NAME
= BROKERKAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR
= 1KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
= 1BROKER_HEAP_OPTS
= -Xmx1G
NOTE: variables referenced in the Apache wrapper scripts are not converted into broker properties.
9092
/var/lib/kafka/data
The image comes with a health check script, /init/healthcheck
, that is pre-configured for non-Kubernetes environments.
version: "3"
services:
zk:
image: itzg/zookeeper
volumes:
- zk:/var/lib/zookeeper/data
kafka-0:
depends_on:
- zk
image: itzg/kafka
environment:
KAFKA_BROKER_ID: "0"
KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://localhost:9092,BROKER://kafka-0:9093"
ports:
- "9092:9092"
volumes:
- kafka-0:/var/lib/kafka/data
volumes:
zk: {}
kafka-0: {}
Example usage with testcontainers
@Testcontainers
public class TestSomethingWithKafka {
private static final Network network = Network.newNetwork();
@Container
private static final GenericContainer zkContainer = new GenericContainer("itzg/zookeeper")
.withNetwork(network)
.withNetworkAliases("zk");
@Container
private static final KafkaContainer kafkaContainer = new KafkaContainer(
DockerImageName.parse("itzg/kafka:3.1.0")
.asCompatibleSubstituteFor("confluentinc/cp-kafka")
)
.dependsOn(zkContainer)
.withNetwork(network)
.withExternalZookeeper("zk:2181");
// ...setup kafka client with "bootstrap.servers" set to kafkaContainer.getBootstrapServers()
}