Kafka broker thinks there are no brokers (not even itself)Kafka failed to map 1073741824 bytes for committing reserved memoryFetching website's logs using Apache Kafka and process it using Spark StreamingGetting error while consuming kafka messageKafka Error: Could not find or load main class config.zookeeper.propertiesNot Kerberized Kafka broker connection to Kerberized ZookeeperKafka setup in windows 10What's the different between ctrl-c and kill -9 when making kafka broker downpackage unable to consume from a partitionUnable to start kafka Broker service in cluster cloudformationI can't run Kafka on windows

Does an ice chest packed full of frozen food need ice?

Recommended tools for graphs and charts

Second (easy access) account in case my bank screws up

Are there downsides to using std::string as a buffer?

Déjà vu, again?

How to handle self harm scars on the arm in work environment?

Why would future John risk sending back a T-800 to save his younger self?

Is the term 'open source' a trademark?

How do governments keep track of their issued currency?

Why did the Herschel Space Telescope need helium coolant?

What is the actual quality of machine translations?

How did old MS-DOS games utilize various graphic cards?

Is it a problem if <h4>, <h5> and <h6> are smaller than regular text?

Mobile App Appraisal

Are there any important biographies of nobodies?

Are there any instruments that don't produce overtones?

What makes an item an artifact?

Taxi Services at Didcot

bash script: "*.jpg" expansion not working as expected inside $(...), for picking a random file

Pre-1972 sci-fi short story or novel: alien(?) tunnel where people try new moves and get destroyed if they're not the correct ones

Should I avoid hard-packed crusher dust trails with my hybrid?

Soft question: Examples where lack of mathematical rigour cause security breaches?

Preventing Employees from either switching to Competitors or Opening Their Own Business

What is the highest possible temporary AC at level 1, without any help from others?



Kafka broker thinks there are no brokers (not even itself)


Kafka failed to map 1073741824 bytes for committing reserved memoryFetching website's logs using Apache Kafka and process it using Spark StreamingGetting error while consuming kafka messageKafka Error: Could not find or load main class config.zookeeper.propertiesNot Kerberized Kafka broker connection to Kerberized ZookeeperKafka setup in windows 10What's the different between ctrl-c and kill -9 when making kafka broker downpackage unable to consume from a partitionUnable to start kafka Broker service in cluster cloudformationI can't run Kafka on windows






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Question



I am trying to run a single Kafka instance in docker. I can create topics but cannot consume from or produce to them. When I try my Kafka broker logs an error message.



kafka_1 | [2019-03-24 16:45:05,263] ERROR [KafkaApi-5] Number of alive brokers '0' does not meet the required replication factor '1' for the offsets topic (configured via 'offsets.topic.replication.factor'). This error can be ignored if the cluster is starting up and not all brokers are up yet. (kafka.server.KafkaApis)


I don't understand the Number of alive brokers '0' bit as it is a Kafka broker that is logging this so surely there must be at least one broker (itself)?



I am using the default server.properties file with the following changes:



listeners=PLAINTEXT://0.0.0.0:9092
advertised.listeners=PLAINTEXT://192.168.0.109:9092
zookeeper.connect=zookeeper:2181


where 192.168.0.109 is my host machine IP.



Files



docker-compose



version: '3.4'
services:
zookeeper:
build:
context: ./
dockerfile: zookeeper.dockerfile
network: host
image: zookeeper
ports:
- "2181:2181"
kafka:
build:
context: ./
dockerfile: kafka.dockerfile
network: host
image: kafka
ports:
- "9092:9092"


kafka.dockerfile



FROM alpine:3.7

# Set the name for a non-priliaged user
ENV APPUSER=appuser

# Install dependnacies
RUN apk add bash
RUN apk add openjdk8-jre

# Add a non-privilaged user and change into it's home directory
RUN adduser -D $APPUSER
WORKDIR /home/$APPUSER

# Download kafka and set its owner to $APPUSER
RUN wget https://www-eu.apache.org/dist/kafka/2.1.0/kafka_2.11-2.1.0.tgz
RUN chown $APPUSER kafka_2.11-2.1.0.tgz

# Change to the non-privilaged user
USER $APPUSER

# Extract kafka
RUN tar -xzf kafka_2.11-2.1.0.tgz

# copy custom server.properties into image
COPY ./server.properties ./

# Set working directory to kafka dir
WORKDIR /home/$APPUSER/kafka_2.11-2.1.0

# start kafka with customer server.properties file
CMD ["bin/kafka-server-start.sh", "../server.properties"]


zookeeper.dockerfile



FROM alpine:3.7

# Set the name for a non-priliaged user
ENV APPUSER=appuser

# Install dependnacies
RUN apk add bash
RUN apk add openjdk8-jre

# Add a non-privilaged user and change into it's home directory
RUN adduser -D $APPUSER
WORKDIR /home/$APPUSER

# Download kafka and set its owner to $APPUSER
RUN wget https://www-eu.apache.org/dist/kafka/2.1.0/kafka_2.11-2.1.0.tgz
RUN chown $APPUSER kafka_2.11-2.1.0.tgz

# Change to the non-privilaged user
USER $APPUSER

# Extract kafka
RUN tar -xzf kafka_2.11-2.1.0.tgz

# Set working directory to kafka dir
WORKDIR /home/$APPUSER/kafka_2.11-2.1.0

# Run zookeeper
CMD ["bin/zookeeper-server-start.sh", "config/zookeeper.properties"]









share|improve this question






















  • Is there a reason you're brewing your own Kafka and ZK docker images, when they exist pre-built already? hub.docker.com/r/confluentinc

    – Robin Moffatt
    Mar 25 at 9:34











  • As a learning exercise. Although I think I actually got a similar error when I used a pre-built image.

    – Michael
    Mar 25 at 20:02











  • Just a suggestion, but maybe start with the pre-built images, since networking and Kafka config can be fiddly. Once you've got that working, move onto the DIY image.

    – Robin Moffatt
    Mar 25 at 20:33











  • playing around with both my setup and the pre-built images as you suggested seems to have highlighted the problem. If I use advertised.listeners=PLAINTEXT://localhost:9092 instead of advertised.listeners=PLAINTEXT://192.168.0.109:9092 everything works. Any idea why?

    – Michael
    Mar 25 at 20:50











  • Turns out it was my firewall setup!

    – Michael
    Mar 25 at 21:13


















0















Question



I am trying to run a single Kafka instance in docker. I can create topics but cannot consume from or produce to them. When I try my Kafka broker logs an error message.



kafka_1 | [2019-03-24 16:45:05,263] ERROR [KafkaApi-5] Number of alive brokers '0' does not meet the required replication factor '1' for the offsets topic (configured via 'offsets.topic.replication.factor'). This error can be ignored if the cluster is starting up and not all brokers are up yet. (kafka.server.KafkaApis)


I don't understand the Number of alive brokers '0' bit as it is a Kafka broker that is logging this so surely there must be at least one broker (itself)?



I am using the default server.properties file with the following changes:



listeners=PLAINTEXT://0.0.0.0:9092
advertised.listeners=PLAINTEXT://192.168.0.109:9092
zookeeper.connect=zookeeper:2181


where 192.168.0.109 is my host machine IP.



Files



docker-compose



version: '3.4'
services:
zookeeper:
build:
context: ./
dockerfile: zookeeper.dockerfile
network: host
image: zookeeper
ports:
- "2181:2181"
kafka:
build:
context: ./
dockerfile: kafka.dockerfile
network: host
image: kafka
ports:
- "9092:9092"


kafka.dockerfile



FROM alpine:3.7

# Set the name for a non-priliaged user
ENV APPUSER=appuser

# Install dependnacies
RUN apk add bash
RUN apk add openjdk8-jre

# Add a non-privilaged user and change into it's home directory
RUN adduser -D $APPUSER
WORKDIR /home/$APPUSER

# Download kafka and set its owner to $APPUSER
RUN wget https://www-eu.apache.org/dist/kafka/2.1.0/kafka_2.11-2.1.0.tgz
RUN chown $APPUSER kafka_2.11-2.1.0.tgz

# Change to the non-privilaged user
USER $APPUSER

# Extract kafka
RUN tar -xzf kafka_2.11-2.1.0.tgz

# copy custom server.properties into image
COPY ./server.properties ./

# Set working directory to kafka dir
WORKDIR /home/$APPUSER/kafka_2.11-2.1.0

# start kafka with customer server.properties file
CMD ["bin/kafka-server-start.sh", "../server.properties"]


zookeeper.dockerfile



FROM alpine:3.7

# Set the name for a non-priliaged user
ENV APPUSER=appuser

# Install dependnacies
RUN apk add bash
RUN apk add openjdk8-jre

# Add a non-privilaged user and change into it's home directory
RUN adduser -D $APPUSER
WORKDIR /home/$APPUSER

# Download kafka and set its owner to $APPUSER
RUN wget https://www-eu.apache.org/dist/kafka/2.1.0/kafka_2.11-2.1.0.tgz
RUN chown $APPUSER kafka_2.11-2.1.0.tgz

# Change to the non-privilaged user
USER $APPUSER

# Extract kafka
RUN tar -xzf kafka_2.11-2.1.0.tgz

# Set working directory to kafka dir
WORKDIR /home/$APPUSER/kafka_2.11-2.1.0

# Run zookeeper
CMD ["bin/zookeeper-server-start.sh", "config/zookeeper.properties"]









share|improve this question






















  • Is there a reason you're brewing your own Kafka and ZK docker images, when they exist pre-built already? hub.docker.com/r/confluentinc

    – Robin Moffatt
    Mar 25 at 9:34











  • As a learning exercise. Although I think I actually got a similar error when I used a pre-built image.

    – Michael
    Mar 25 at 20:02











  • Just a suggestion, but maybe start with the pre-built images, since networking and Kafka config can be fiddly. Once you've got that working, move onto the DIY image.

    – Robin Moffatt
    Mar 25 at 20:33











  • playing around with both my setup and the pre-built images as you suggested seems to have highlighted the problem. If I use advertised.listeners=PLAINTEXT://localhost:9092 instead of advertised.listeners=PLAINTEXT://192.168.0.109:9092 everything works. Any idea why?

    – Michael
    Mar 25 at 20:50











  • Turns out it was my firewall setup!

    – Michael
    Mar 25 at 21:13














0












0








0








Question



I am trying to run a single Kafka instance in docker. I can create topics but cannot consume from or produce to them. When I try my Kafka broker logs an error message.



kafka_1 | [2019-03-24 16:45:05,263] ERROR [KafkaApi-5] Number of alive brokers '0' does not meet the required replication factor '1' for the offsets topic (configured via 'offsets.topic.replication.factor'). This error can be ignored if the cluster is starting up and not all brokers are up yet. (kafka.server.KafkaApis)


I don't understand the Number of alive brokers '0' bit as it is a Kafka broker that is logging this so surely there must be at least one broker (itself)?



I am using the default server.properties file with the following changes:



listeners=PLAINTEXT://0.0.0.0:9092
advertised.listeners=PLAINTEXT://192.168.0.109:9092
zookeeper.connect=zookeeper:2181


where 192.168.0.109 is my host machine IP.



Files



docker-compose



version: '3.4'
services:
zookeeper:
build:
context: ./
dockerfile: zookeeper.dockerfile
network: host
image: zookeeper
ports:
- "2181:2181"
kafka:
build:
context: ./
dockerfile: kafka.dockerfile
network: host
image: kafka
ports:
- "9092:9092"


kafka.dockerfile



FROM alpine:3.7

# Set the name for a non-priliaged user
ENV APPUSER=appuser

# Install dependnacies
RUN apk add bash
RUN apk add openjdk8-jre

# Add a non-privilaged user and change into it's home directory
RUN adduser -D $APPUSER
WORKDIR /home/$APPUSER

# Download kafka and set its owner to $APPUSER
RUN wget https://www-eu.apache.org/dist/kafka/2.1.0/kafka_2.11-2.1.0.tgz
RUN chown $APPUSER kafka_2.11-2.1.0.tgz

# Change to the non-privilaged user
USER $APPUSER

# Extract kafka
RUN tar -xzf kafka_2.11-2.1.0.tgz

# copy custom server.properties into image
COPY ./server.properties ./

# Set working directory to kafka dir
WORKDIR /home/$APPUSER/kafka_2.11-2.1.0

# start kafka with customer server.properties file
CMD ["bin/kafka-server-start.sh", "../server.properties"]


zookeeper.dockerfile



FROM alpine:3.7

# Set the name for a non-priliaged user
ENV APPUSER=appuser

# Install dependnacies
RUN apk add bash
RUN apk add openjdk8-jre

# Add a non-privilaged user and change into it's home directory
RUN adduser -D $APPUSER
WORKDIR /home/$APPUSER

# Download kafka and set its owner to $APPUSER
RUN wget https://www-eu.apache.org/dist/kafka/2.1.0/kafka_2.11-2.1.0.tgz
RUN chown $APPUSER kafka_2.11-2.1.0.tgz

# Change to the non-privilaged user
USER $APPUSER

# Extract kafka
RUN tar -xzf kafka_2.11-2.1.0.tgz

# Set working directory to kafka dir
WORKDIR /home/$APPUSER/kafka_2.11-2.1.0

# Run zookeeper
CMD ["bin/zookeeper-server-start.sh", "config/zookeeper.properties"]









share|improve this question














Question



I am trying to run a single Kafka instance in docker. I can create topics but cannot consume from or produce to them. When I try my Kafka broker logs an error message.



kafka_1 | [2019-03-24 16:45:05,263] ERROR [KafkaApi-5] Number of alive brokers '0' does not meet the required replication factor '1' for the offsets topic (configured via 'offsets.topic.replication.factor'). This error can be ignored if the cluster is starting up and not all brokers are up yet. (kafka.server.KafkaApis)


I don't understand the Number of alive brokers '0' bit as it is a Kafka broker that is logging this so surely there must be at least one broker (itself)?



I am using the default server.properties file with the following changes:



listeners=PLAINTEXT://0.0.0.0:9092
advertised.listeners=PLAINTEXT://192.168.0.109:9092
zookeeper.connect=zookeeper:2181


where 192.168.0.109 is my host machine IP.



Files



docker-compose



version: '3.4'
services:
zookeeper:
build:
context: ./
dockerfile: zookeeper.dockerfile
network: host
image: zookeeper
ports:
- "2181:2181"
kafka:
build:
context: ./
dockerfile: kafka.dockerfile
network: host
image: kafka
ports:
- "9092:9092"


kafka.dockerfile



FROM alpine:3.7

# Set the name for a non-priliaged user
ENV APPUSER=appuser

# Install dependnacies
RUN apk add bash
RUN apk add openjdk8-jre

# Add a non-privilaged user and change into it's home directory
RUN adduser -D $APPUSER
WORKDIR /home/$APPUSER

# Download kafka and set its owner to $APPUSER
RUN wget https://www-eu.apache.org/dist/kafka/2.1.0/kafka_2.11-2.1.0.tgz
RUN chown $APPUSER kafka_2.11-2.1.0.tgz

# Change to the non-privilaged user
USER $APPUSER

# Extract kafka
RUN tar -xzf kafka_2.11-2.1.0.tgz

# copy custom server.properties into image
COPY ./server.properties ./

# Set working directory to kafka dir
WORKDIR /home/$APPUSER/kafka_2.11-2.1.0

# start kafka with customer server.properties file
CMD ["bin/kafka-server-start.sh", "../server.properties"]


zookeeper.dockerfile



FROM alpine:3.7

# Set the name for a non-priliaged user
ENV APPUSER=appuser

# Install dependnacies
RUN apk add bash
RUN apk add openjdk8-jre

# Add a non-privilaged user and change into it's home directory
RUN adduser -D $APPUSER
WORKDIR /home/$APPUSER

# Download kafka and set its owner to $APPUSER
RUN wget https://www-eu.apache.org/dist/kafka/2.1.0/kafka_2.11-2.1.0.tgz
RUN chown $APPUSER kafka_2.11-2.1.0.tgz

# Change to the non-privilaged user
USER $APPUSER

# Extract kafka
RUN tar -xzf kafka_2.11-2.1.0.tgz

# Set working directory to kafka dir
WORKDIR /home/$APPUSER/kafka_2.11-2.1.0

# Run zookeeper
CMD ["bin/zookeeper-server-start.sh", "config/zookeeper.properties"]






docker apache-kafka






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 17:10









MichaelMichael

164118




164118












  • Is there a reason you're brewing your own Kafka and ZK docker images, when they exist pre-built already? hub.docker.com/r/confluentinc

    – Robin Moffatt
    Mar 25 at 9:34











  • As a learning exercise. Although I think I actually got a similar error when I used a pre-built image.

    – Michael
    Mar 25 at 20:02











  • Just a suggestion, but maybe start with the pre-built images, since networking and Kafka config can be fiddly. Once you've got that working, move onto the DIY image.

    – Robin Moffatt
    Mar 25 at 20:33











  • playing around with both my setup and the pre-built images as you suggested seems to have highlighted the problem. If I use advertised.listeners=PLAINTEXT://localhost:9092 instead of advertised.listeners=PLAINTEXT://192.168.0.109:9092 everything works. Any idea why?

    – Michael
    Mar 25 at 20:50











  • Turns out it was my firewall setup!

    – Michael
    Mar 25 at 21:13


















  • Is there a reason you're brewing your own Kafka and ZK docker images, when they exist pre-built already? hub.docker.com/r/confluentinc

    – Robin Moffatt
    Mar 25 at 9:34











  • As a learning exercise. Although I think I actually got a similar error when I used a pre-built image.

    – Michael
    Mar 25 at 20:02











  • Just a suggestion, but maybe start with the pre-built images, since networking and Kafka config can be fiddly. Once you've got that working, move onto the DIY image.

    – Robin Moffatt
    Mar 25 at 20:33











  • playing around with both my setup and the pre-built images as you suggested seems to have highlighted the problem. If I use advertised.listeners=PLAINTEXT://localhost:9092 instead of advertised.listeners=PLAINTEXT://192.168.0.109:9092 everything works. Any idea why?

    – Michael
    Mar 25 at 20:50











  • Turns out it was my firewall setup!

    – Michael
    Mar 25 at 21:13

















Is there a reason you're brewing your own Kafka and ZK docker images, when they exist pre-built already? hub.docker.com/r/confluentinc

– Robin Moffatt
Mar 25 at 9:34





Is there a reason you're brewing your own Kafka and ZK docker images, when they exist pre-built already? hub.docker.com/r/confluentinc

– Robin Moffatt
Mar 25 at 9:34













As a learning exercise. Although I think I actually got a similar error when I used a pre-built image.

– Michael
Mar 25 at 20:02





As a learning exercise. Although I think I actually got a similar error when I used a pre-built image.

– Michael
Mar 25 at 20:02













Just a suggestion, but maybe start with the pre-built images, since networking and Kafka config can be fiddly. Once you've got that working, move onto the DIY image.

– Robin Moffatt
Mar 25 at 20:33





Just a suggestion, but maybe start with the pre-built images, since networking and Kafka config can be fiddly. Once you've got that working, move onto the DIY image.

– Robin Moffatt
Mar 25 at 20:33













playing around with both my setup and the pre-built images as you suggested seems to have highlighted the problem. If I use advertised.listeners=PLAINTEXT://localhost:9092 instead of advertised.listeners=PLAINTEXT://192.168.0.109:9092 everything works. Any idea why?

– Michael
Mar 25 at 20:50





playing around with both my setup and the pre-built images as you suggested seems to have highlighted the problem. If I use advertised.listeners=PLAINTEXT://localhost:9092 instead of advertised.listeners=PLAINTEXT://192.168.0.109:9092 everything works. Any idea why?

– Michael
Mar 25 at 20:50













Turns out it was my firewall setup!

– Michael
Mar 25 at 21:13






Turns out it was my firewall setup!

– Michael
Mar 25 at 21:13













1 Answer
1






active

oldest

votes


















0














This is down to the listeners configuration.



When you specify advertised.listeners=PLAINTEXT://192.168.0.109:9092 then Kafka will try to connect to 192.168.0.109 from within the Docker container. But if this is a host address, and if you've not set up the appropriate Docker networking wizardry, it will fail.



When you specify advertised.listeners=PLAINTEXT://localhost:9092 then Kafka will connect to localhost within the Docker container, which of course resolves to itself. The catch here is that you would be unable to use a Kafka client outside of the Docker container (either on your host machine, or another Docker container) because they would try to connect to localhostlocally to themselves on which there would not be a Kafka broker.



This article explains in more detail the issue, and appropriate configuration to use. If you want a pre-built example of Kafka in Docker then this Docker Compose shows it.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55326352%2fkafka-broker-thinks-there-are-no-brokers-not-even-itself%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    This is down to the listeners configuration.



    When you specify advertised.listeners=PLAINTEXT://192.168.0.109:9092 then Kafka will try to connect to 192.168.0.109 from within the Docker container. But if this is a host address, and if you've not set up the appropriate Docker networking wizardry, it will fail.



    When you specify advertised.listeners=PLAINTEXT://localhost:9092 then Kafka will connect to localhost within the Docker container, which of course resolves to itself. The catch here is that you would be unable to use a Kafka client outside of the Docker container (either on your host machine, or another Docker container) because they would try to connect to localhostlocally to themselves on which there would not be a Kafka broker.



    This article explains in more detail the issue, and appropriate configuration to use. If you want a pre-built example of Kafka in Docker then this Docker Compose shows it.






    share|improve this answer



























      0














      This is down to the listeners configuration.



      When you specify advertised.listeners=PLAINTEXT://192.168.0.109:9092 then Kafka will try to connect to 192.168.0.109 from within the Docker container. But if this is a host address, and if you've not set up the appropriate Docker networking wizardry, it will fail.



      When you specify advertised.listeners=PLAINTEXT://localhost:9092 then Kafka will connect to localhost within the Docker container, which of course resolves to itself. The catch here is that you would be unable to use a Kafka client outside of the Docker container (either on your host machine, or another Docker container) because they would try to connect to localhostlocally to themselves on which there would not be a Kafka broker.



      This article explains in more detail the issue, and appropriate configuration to use. If you want a pre-built example of Kafka in Docker then this Docker Compose shows it.






      share|improve this answer

























        0












        0








        0







        This is down to the listeners configuration.



        When you specify advertised.listeners=PLAINTEXT://192.168.0.109:9092 then Kafka will try to connect to 192.168.0.109 from within the Docker container. But if this is a host address, and if you've not set up the appropriate Docker networking wizardry, it will fail.



        When you specify advertised.listeners=PLAINTEXT://localhost:9092 then Kafka will connect to localhost within the Docker container, which of course resolves to itself. The catch here is that you would be unable to use a Kafka client outside of the Docker container (either on your host machine, or another Docker container) because they would try to connect to localhostlocally to themselves on which there would not be a Kafka broker.



        This article explains in more detail the issue, and appropriate configuration to use. If you want a pre-built example of Kafka in Docker then this Docker Compose shows it.






        share|improve this answer













        This is down to the listeners configuration.



        When you specify advertised.listeners=PLAINTEXT://192.168.0.109:9092 then Kafka will try to connect to 192.168.0.109 from within the Docker container. But if this is a host address, and if you've not set up the appropriate Docker networking wizardry, it will fail.



        When you specify advertised.listeners=PLAINTEXT://localhost:9092 then Kafka will connect to localhost within the Docker container, which of course resolves to itself. The catch here is that you would be unable to use a Kafka client outside of the Docker container (either on your host machine, or another Docker container) because they would try to connect to localhostlocally to themselves on which there would not be a Kafka broker.



        This article explains in more detail the issue, and appropriate configuration to use. If you want a pre-built example of Kafka in Docker then this Docker Compose shows it.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 21:16









        Robin MoffattRobin Moffatt

        9,2471631




        9,2471631





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55326352%2fkafka-broker-thinks-there-are-no-brokers-not-even-itself%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript