title: Can't connect to dockerized kafka (used wurstmeister/kafka-docker) from outside the server
body: <p>I'm trying to connect kafka, which is running on docker conatiner (on EC2 server).<br><br>
  I cloned <a href="https://github.com/wurstmeister/kafka-docker" rel="nofollow noreferrer">wurstmeister/kafka-docker</a>, and edited <code>docker-compose-single-broker.yml</code> file like below.</p>
  <pre><code>
  version: &quot;2&quot;
  services:
    zookeeper:
      image: wurstmeister/zookeeper
      ports:
        - &quot;2181:2181&quot;
    kafka:
      build: .
      ports:
        - &quot;8092:9092&quot;
      environment:
        KAFKA_ADVERTISED_HOST_NAME: 111.11.11.111 # (my EC2 server ip address)
        KAFKA_CREATE_TOPICS: &quot;test-topic:1:1&quot; # topic_name:partition:replica
        KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
  </code></pre>
  <p>I changed port <code>9092:9092</code> to <code>8092:9092</code>, because my EC2 server doesn't allow port over 9000.<br>Ip <code>111.11.11.111</code> is an example.<br><br></p>
  <p>With this docker-compose, I successfully started kafka and zookeeper container.
  Then, I used console-producer and console-consumer on same EC2 server to test kafka connection like below.<br><code>$ bin/kafka-console-producer.sh --broker-list 111.11.11.111:8092 --topic test-topic</code><br><code>$ bin/kafka-console-consumer.sh --bootstrap-server 111.11.11.111:8092 --topic test-topic --from-beginning</code><br><br></p>
  <p>It worked well on my EC2 server, but I couldn't do the same on my local shell.
  It seems like it doesn't allow access from outside the server.
  How can I change my docker-compose file to make it possible to access from other server?</p>