obsidiandynamics/kafka

By obsidiandynamics

Updated over 5 years ago

Combined Kafka and ZooKeeper image

Image
9

1M+

Conveniently combines ZooKeeper and Kafka into a single image.

Supports Kafka 2.3.0

Running

Example: vanilla broker setup

docker run --name kafka --rm -it -p 2181:2181 -p 9092:9092 obsidiandynamics/kafka

Example: advertising the listener on an alternate hostname

Advertising on kafka:9092 rather than the default localhost:9092:

docker run --name kafka --rm -it -p 2181:2181 -p 9092:9092 \
    -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092 \
    obsidiandynamics/kafka

Example: multiple advertised listeners

Advertising on kafka:29092 and localhost:9092:

docker run --name kafka --rm -it -p 2181:2181 -p 9092:9092 -p 29092:29092 \
    -e KAFKA_LISTENERS=INTERNAL://:29092,EXTERNAL://:9092 \
    -e KAFKA_ADVERTISED_LISTENERS=INTERNAL://kafka:29092,EXTERNAL://localhost:9092 \
    -e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT \
    -e KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL \
    obsidiandynamics/kafka

Configuring

Configuration is administered through environment variables.

VariableDefaultDescription
KAFKA_BROKER_ID0The broker ID (set to -1 to generate a unique ID)
KAFKA_LISTENERSPLAINTEXT://:9092Address(es) the socket server listens on (comma-separated)
KAFKA_ADVERTISED_LISTENERSThe value of KAFKA_LISTENERSHostname/port combination(s) the broker will advertise to clients (comma-separated)
KAFKA_LISTENER_SECURITY_PROTOCOL_MAPPLAINTEXT:PLAINTEXT, SSL:SSL, SASL_PLAINTEXT:SASL_PLAINTEXT, SASL_SSL:SASL_SSLMaps listener names to security protocols
KAFKA_INTER_BROKER_LISTENER_NAMEPLAINTEXTThe listener to use for inter-broker communications
KAFKA_ADVERTISED_HOST_NAMEThe canonical hostname of the machineThe advertised hostname (deprecated, prefer KAFKA_ADVERTISED_LISTENERS instead)
KAFKA_ADVERTISED_PORTThe value of the bound portThe advertised port (deprecated, prefer KAFKA_ADVERTISED_LISTENERS instead)
KAFKA_ZOOKEEPER_CONNECT127.0.0.1:2181 ZooKeeper connect address
KAFKA_ZOOKEEPER_CONNECTION_TIMEOUT10000ZooKeeper connect timeout
KAFKA_ZOOKEEPER_SESSION_TIMEOUT6000ZooKeeper session timeout
KAFKA_RESTART_ATTEMPTS3Number of times to restart the broker if it terminates with a non-zero exit code
KAFKA_RESTART_DELAY5Number of seconds between restart attempts
ZOOKEEPER_AUTOPURGE_PURGE_INTERVAL0ZooKeeper auto-purge interval (in hours, set to 0 to disable)

Docker Pull Command

docker pull obsidiandynamics/kafka