title: Kafka broker thinks there are no brokers (not even itself)
body: <h1>Question</h1>
  
  <p>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.</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>I don't understand the <code>Number of alive brokers '0'</code> bit as it is a Kafka broker that is logging this so surely there must be at least one broker (itself)?</p>
  
  <p>I am using the default <code>server.properties</code> file with the following changes:</p>
  
  <pre><code>listeners=PLAINTEXT://0.0.0.0:9092
  advertised.listeners=PLAINTEXT://192.168.0.109:9092
  zookeeper.connect=zookeeper:2181
  </code></pre>
  
  <p>where <code>192.168.0.109</code> is my host machine IP.</p>
  
  <h1>Files</h1>
  
  <h2>docker-compose</h2>
  
  <pre><code>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"
  </code></pre>
  
  <h2>kafka.dockerfile</h2>
  
  <pre><code>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"]
  </code></pre>
  
  <h2>zookeeper.dockerfile</h2>
  
  <pre><code>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"]
  </code></pre>