spotify / docker-kafka

Kafka (and Zookeeper) in Docker
Apache License 2.0
1.4k stars 643 forks source link

Kafka example not working (with 0.10) #62

Closed bluepuma77 closed 7 years ago

bluepuma77 commented 7 years ago

For me the example with kafka-console-producer.sh and kafka-console-consumer.sh does not seem to work. No output from producer and no output from consumer. And when I close the consumer it tells me Processed a total of 0 messages.

# variables for all terminals
export IP=$(ifconfig eth0 | grep "inet addr:" | cut -d ":" -f2 | cut -d " " -f1)
export KAFKA=$IP:9092
export ZOOKEEPER=$IP:2181

# terminal 1
docker run \
  --name kafka \
  --restart=always \
  -p 2181:2181 \
  -p 9092:9092 \
  --env ADVERTISED_HOST=$IP\
  --env ADVERTISED_PORT=9092 \
  spotify/kafka

# terminal 2
docker run -it --rm spotify/kafka /opt/kafka_2.11-0.10.1.0/bin/kafka-console-producer.sh --broker-list $KAFKA --topic test

# terminal 3
docker run -it --rm spotify/kafka /opt/kafka_2.11-0.10.1.0/bin/kafka-console-consumer.sh --zookeeper $ZOOKEEPER --topic test
bluepuma77 commented 7 years ago

I tried to reproduce it with the old kafka 0.8 version from this repo, there I get an error with the producer WARN Property topic is not valid (kafka.utils.VerifiableProperties). Has this worked at some point in time?

# building with kafka 0.8
git clone https://github.com/spotify/docker-kafka
git reset --hard 170791da720498457ec545d97b7e43f13e28946f
cd kafka
docker build -t kafka:0.8 .

# variables for all terminals
export IP=$(ifconfig eth0 | grep "inet addr:" | cut -d ":" -f2 | cut -d " " -f1)
export KAFKA=$IP:9092
export ZOOKEEPER=$IP:2181

# terminal 1
docker run \
  --name kafka \
  --restart=always \
  -p 2181:2181 \
  -p 9092:9092 \
  --env ADVERTISED_HOST=$IP\
  --env ADVERTISED_PORT=9092 \
  kafka:0.8

# terminal 2
docker run -it --rm kafka:0.8 /opt/kafka_2.11-0.8.2.1/bin/kafka-console-producer.sh --broker-list $KAFKA --topic test

# terminal 3
docker run -it --rm kafka:0.8 /opt/kafka_2.11-0.8.2.1/bin/kafka-console-consumer.sh --zookeeper $ZOOKEEPER --topic test
bluepuma77 commented 7 years ago

Sorry, my mistake, I thought the kafka-console-producer.sh would automatically produce demo messages by itself. Instead I had to enter characters and press return for it to be sent to kafka and read by kafka-console-consumer.sh. So the latest kafka 0.10.1.0 docker image seems to work.