Coder Social home page Coder Social logo

Comments (7)

jeffijoe avatar jeffijoe commented on August 19, 2024

Running kafkacat to list the broker meta, I get:

Metadata for all topics (from broker -1: localhost:20031/bootstrap):
 3 brokers:
  broker 2 at kafka2:9093
  broker 1 at kafka1:9092
  broker 3 at kafka3:9094

Which should have been 10.0.1.9:20031 and so on. If I use the same host and container port, then the IP is displayed correctly, and everything works.

Is it possible to change the host ports without breaking things? πŸ˜„

from kafka-stack-docker-compose.

simplesteph avatar simplesteph commented on August 19, 2024

yes. Updated README

Q: Can I change the zookeeper ports?

A: yes. Say you want to change zoo1 port to 12181 (only relevant lines are shown):

  zoo1:
    ports:
      - "12181:12181"
    environment:
        ZOO_PORT: 12181
        
  kafka1:
    environment:
      KAFKA_ZOOKEEPER_CONNECT: "zoo1:12181"

Q: Can I change the Kafka ports?

A: yes. Say you want to change kafka1 port to 12345 (only relevant lines are shown). Note only LISTENER_DOCKER_EXTERNAL changes:

  kafka1:
    image: confluentinc/cp-kafka:5.0.0
    hostname: kafka1
    ports:
      - "12345:12345"
    environment:
      KAFKA_ADVERTISED_LISTENERS: LISTENER_DOCKER_INTERNAL://kafka1:19092,LISTENER_DOCKER_EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:12345

from kafka-stack-docker-compose.

jeffijoe avatar jeffijoe commented on August 19, 2024

Thanks!

Curious, why does host and container port have to be the same?

from kafka-stack-docker-compose.

simplesteph avatar simplesteph commented on August 19, 2024

Have a look through the blog at the top of the readme

from kafka-stack-docker-compose.

jeffijoe avatar jeffijoe commented on August 19, 2024

I read the entire thing πŸ˜„ I still don't understand why the ports need to be the same in order for it to advertise the correct host and port when connecting externally?

from kafka-stack-docker-compose.

simplesteph avatar simplesteph commented on August 19, 2024
  1. client connects to Kafka on port A
  2. Kafka responds and says btw I run on port B and you should use B
  3. client tries to connect to Kafka on port B

If A!=B then things will be problematic
This is due to how Kafka implements broker discovery. Each broker knows best how to be connected to it and clients have to use what brokers advertise

from kafka-stack-docker-compose.

jeffijoe avatar jeffijoe commented on August 19, 2024

I can't find any documentation regarding all listeners requiring the use of the same port though? Do you think it's a Kafka bug?

from kafka-stack-docker-compose.

Related Issues (20)

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.