spotify / docker-kafka

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

Has anyone been able to start a topic using Docker Compose? #75

Open andrewterra opened 7 years ago

andrewterra commented 7 years ago

I attempted to put

kafka:
    image: spotify/kafka
    ports:
      - "9092:9092"
      - "2181:2181"
    hostname: kafka
    expose:
      - "9092"
      - "2181"
    environment:
      TOPICS: test-topic

But this failed to work, is there something that I'm missing? (I tried with quotes around the topic as well)

Also, if anyone has had any luck using Spring to connect to a topic, I would greatly appreciate some help connecting to the topics.

pugna0 commented 6 years ago

TOPICS env is for spotify/kafkaproxy image.

shankarshastri commented 6 years ago
kafka:
  image: spotify/kafka
  ports:
  - "2181:2181"
  - "9092:9092"
  hostname: kafka
  container_name: kafka
  environment:
  - "ADVERTISED_HOST=kafka"
  - "ADVERTISED_PORT=9092"
  - "AUTO_CREATE_TOPICS=true"
  command: >
      bash -c
      "(sleep 15s &&
      /opt/kafka_2.11-0.10.1.0/bin/kafka-topics.sh
      --create
      --zookeeper
      localhost:2181 --replication-factor 1 --partitions 1
      --topic dummy_topic &) && (supervisord -n)"

@terrabl, you can do it like this.

Dusanlex commented 6 years ago

Hi there, I have a question. How can I create producer and consumer in "command" section like this topic was created?

pravinsakthivel commented 5 years ago

Hi there, I have a question. How can I create producer and consumer in "command" section like this topic was created? Refer below link: https://gist.github.com/abacaphiliac/f0553548f9c577214d16290c2e751071

jmayday commented 5 years ago

AUTO_CREATE_TOPICS

Is this variable really needed? I've managed to get my topic created even without this variable. Could you please explain reason why we need it?

pavanarya commented 4 years ago

I did a NuGet package update and that solved my issue