Kafka docker image using OpenJDK and more specifically eclipse-temurin:17-jre-jammy as base image.
Currently images are being produced for these os/arch:
linux/amd64linux/arm/v7linux/arm64/v8Docker Hub: https://hub.docker.com/r/moukoublen/kafka.
GitHub: https://github.com/moukoublen/docker-kafka.
Based on the excellent work of wurstmeister/kafka
Schema: <scala version>-<kafka version>
3.4.1-2.13, latest3.4.1-2.123.4.0-2.133.4.0-2.123.3.2-2.133.3.2-2.123.3.1-2.133.3.1-2.122.8.2-2.132.8.2-2.12CONFIG_SOURCEenv)In order to use environment variables as configuration you must initialize env var CONFIG_SOURCE with env value (CONFIG_SOURCE: env).
Use properties from broker config directly as environment variables with server. prefix. Also log4j properties can be used direclty using log4j. prefix.
Table of environment variables prefix and destination file.
| Prefix | Destination file |
|---|---|
server | ${KAFKA_HOME}/config/server.properties |
log4j | ${KAFKA_HOME}/config/log4j.properties" |
version: '3.8'
services:
kafka:
image: moukoublen/kafka
ports:
- "9094:9094"
environment:
KAFKA_HEAP_OPTS: -Xmx2g -Xms2g
CONFIG_SOURCE: env
server.broker.id: 1
server.zookeeper.connect: zookeeper:2181
server.listeners: INSIDE://kafka:9092,OUTSIDE://kafka:9094
server.advertised.listeners: INSIDE://kafka:9092,OUTSIDE://localhost:9094
server.listener.security.protocol.map: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
server.inter.broker.listener.name: INSIDE
server.auto.create.topics.enable: "false"
log4j.logger.kafka: DEBUG
log4j.logger.org.apache.kafka: DEBUG
restart: on-failure
files)By setting CONFIG_SOURCE to files (e.g. CONFIG_SOURCE: files) conf files remain untouched and can be passed as link.
version: '3.8'
services:
kafka:
image: moukoublen/kafka
ports:
- "9094:9094"
environment:
KAFKA_HEAP_OPTS: -Xmx2g -Xms2g
CONFIG_SOURCE: files
volumes:
- $PWD/config/server.properties:/opt/kafka/config/server.properties
- $PWD/config/log4j.properties:/opt/kafka/config/log4j.properties
restart: on-failure
An easy way to create topics using docker compose is this:
services:
zookeeper:
# ...
kafka:
# ...
environment:
server.listeners: INSIDE://kafka:9092,OUTSIDE://kafka:9094
server.advertised.listeners: INSIDE://kafka:9092,OUTSIDE://localhost:9094
# ...
topics-seed:
image: moukoublen/kafka:latest
restart: on-failure
command: >
bash -c "set -ex
kafka-topics.sh --bootstrap-server 'INSIDE://kafka:9092' --create --topic samples1 --if-not-exists
"
Check single-kafka.yml and kraft-cluster.yml for example.
Single kafka node
docker compose -f compose/single-kafka.yml up
Cluster with zookeeper
docker compose -f compose/cluster-kafka.yml up
Kraft cluster (with external mounting of kafka log directory)
mkdir -p ./compose/logs/kraft-kafka{1,2,3}
docker compose -f compose/kraft-cluster.yml up
Content type
Image
Digest
sha256:83afb4a22…
Size
238.1 MB
Last updated
almost 3 years ago
docker pull moukoublen/kafka