Coder Social home page Coder Social logo

docker-kafka's Introduction

docker-kafka

Kafka docker compose stack using Bitnami Kafka images.

  • Kafka data is persisted into ./kafka that bind in docker compose volume mount.

  • Kafka broker is available to all peer containers through hostname (i.e. docker compose service name) kafka.

  • Therefore, an example producer and consumer config in your app might be as follows:

    vi config.yml
    
      kafka_producer:
        bootstrap.servers: kafka:9092
        key.serializer: org.apache.kafka.common.serialization.StringSerializer
        value.serializer: org.apache.kafka.common.serialization.StringSerializer
        acks: 1
        retries: 3
        linger.ms: 1
      
      kafka_consumer:
        bootstrap.servers: kafka:9092
        key.deserializer: org.apache.kafka.common.serialization.StringDeserializer
        value.deserializer: org.apache.kafka.common.serialization.StringDeserializer
        group.id: "test"
        enable.auto.commit: false
        auto.offset.reset: 'earliest'
    

Access from host server machine

  • To access Kafka broker from host, first append kafka hostname to localhost loopback like so:

    vi /etc/hosts
      127.0.0.1  localhost  kafka
    
  • Then do like so:

    wget http://mirror.intergrid.com.au/apache/kafka/2.0.0/kafka_2.12-2.0.0.tgz
    tar xzf kafka_2.12-2.0.0.tgz
    
    Term1:
    bin/kafka-console-producer.sh --broker-list kafka:9092 --topic test
    
    
    Term2:
    bin/kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic test --from-beginning
    

Access from remote client through SSH tunnel

  • Similarly, modify hosts file of your remote client machine to add kafka hostname to localhost loopback

    vi /etc/hosts
      127.0.0.1  localhost  kafka
    
  • Then, punch the tunnel like so:

    ssh -L kafka:2181:kafka:2181 -L kafka:9092:kafka:9092 [email protected]
    

docker-kafka's People

Contributors

victorskl avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.