Public | Automated Build

Last pushed: 25 days ago
Short Description
Alpine Linux based Kafka Docker Image
Full Description

docker-kafka-alpine

Alpine Linux based Kafka Docker Image

Dependencies

Image Tags

REPOSITORY          TAG                 SIZE
blacktop/kafka      latest              226MB
blacktop/kafka      0.11                226MB
blacktop/kafka      0.10                223MB
blacktop/kafka      0.9                 238.6MB
blacktop/kafka      0.8                 227.5MB

Getting Started

NOTE: I am assuming use of Docker for Mac with these examples. (KAFKA_ADVERTISED_HOST_NAME=localhost)

docker run -d \
           --name kafka \
           -p 9092:9092 \
           -e KAFKA_ADVERTISED_HOST_NAME=localhost \
           -e KAFKA_CREATE_TOPICS="test-topic:1:1" \
           blacktop/kafka

This will create a single-node kafka broker (listening on localhost:9092), a local zookeeper instance and create the topic test-topic with 1 replication-factor and 1 partition.

You can now test your new single-node kafka broker using Shopify/sarama's kafka-console-producer and kafka-console-consumer

Required

$ go get github.com/Shopify/sarama/tools/kafka-console-consumer
$ go get github.com/Shopify/sarama/tools/kafka-console-producer

Now start a consumer in the background and then send some data to kafka via a producer

$ kafka-console-consumer --bootstrap-server=localhost:9092 --topic=test-topic &
$ echo "shrinky-dinks" | kafka-console-producer --broker-list=localhost:9092 --topic=test-topic

Documentation

Issues

Find a bug? Want more features? Find something missing in the documentation? Let me know! Please don't hesitate to file an issue

Credits

Heavily (if not entirely) influenced by https://github.com/wurstmeister/kafka-docker

Todo

  • [x] Add ability to run a single node kafka broker when you don't supply a zookeeper link.

CHANGELOG

See CHANGELOG.md

Contributing

See all contributors on GitHub.

Please update the CHANGELOG.md and submit a Pull Request on GitHub.

License

MIT Copyright (c) 2016-2017 blacktop

Docker Pull Command
Owner
blacktop
Source Repository

Comments (1)
dmlond
a year ago

I was able to get a single node kafka server running on docker for mac with the following docker-compose.yml

version: "2"

services:
  zookeeper:
    container_name: zookeeper
    image: blacktop/kafka:0.10
    command: zookeeper-server-start.sh config/zookeeper.properties
    ports:
      - 2181:2181
    network_mode: bridge
  kafka:
    image: blacktop/kafka:0.10
    depends_on:
      - zookeeper
    entrypoint: /wait-for-it.sh zookeeper:2181 -s --timeout=5 -- /kafka-entrypoint.sh
    command: kafka-server-start.sh config/server.properties
    environment:
      KAFKA_ADVERTISED_HOST_NAME: kafka
      KAFKA_ADVERTISED_PORT: 9092
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_HEAP_OPTS: "-Xmx2G -Xms2G"
    ports:
      - 9092:9092
    links:
     - zookeeper
    extra_hosts:
      - "kafka:127.0.0.1"
    volumes:
      # - kafka-logs:/tmp/kafka-logs
      - /var/run/docker.sock:/var/run/docker.sock
    network_mode: bridge
# volumes:
#   kafka-logs:

this comment mentions that kafka wants to ping its own advertised hostname when a producer connects to post a message. So, the challenge is to ensure that:

  • the internal container port is the same as the external exposed port
  • the advertised hostname is accessible inside the container as well as outside the container
    I havent figured out how to do this yet.