title: Starting a Kafka topics using Docker Compose with spotify/kafka?
body: <p>I am attempting to connect Kafka topics to my front-end Java Spring application.  I am utilizing Docker Compose and have tried to connect using two different Kafka images.</p>
  
  <p>With <a href="https://github.com/wurstmeister/kafka-docker" rel="noreferrer">wurstmeister/kafka</a> I have been able to get the Kafka topics up and running by this service in my <code>docker.compose.yml</code> file. But I have not been able to connect the created topics to my front-end Java Spring application. </p>
  
  <pre><code>kafka:
      image: wurstmeister/kafka:0.10.2.0
      ports:
        - "9092:9092"
      expose:
        - "9092"
        - "2181"
      environment:
        KAFKA_ADVERTISED_HOST_NAME: localhost
        KAFKA_CREATE_TOPICS: "test-topic1:1:1, test-topic2:1:1"
        KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
      depends_on:
        - zookeeper
  </code></pre>
  
  <p>Secondly, with <a href="https://github.com/spotify/docker-kafka" rel="noreferrer">spotify/kafka</a>, I am having difficulty actually creating the topics with Kafka. In the documentation, it is looking for the topics as an environment variable, but the following <code>docker-compose.yml</code> service is not creating a topic. I have also tried putting quotes around the <code>test-topic</code> but that did not work as well. </p>
  
  <pre><code>kafka:
      image: spotify/kafka
      ports:
        - "9092:9092"
        - "2181:2181"
      hostname: kafka
      expose:
        - "9092"
        - "2181"
      environment:
        TOPICS: test-topic
  </code></pre>
  
  <p>I do not know if this is necessary, but my entire <code>docker-compose.yml</code> file is as follows, take note that the zookeeper service is only required if you use <code>wurstmeister/kafka</code>.</p>
  
  <p><strong><code>docker-compose.yml</code></strong></p>
  
  <pre><code>version: '2'
  services:
    # zookeeper:
    #   image: wurstmeister/zookeeper
    #   ports:
    #     - "2181:2181"
    kafka:
      image: spotify/kafka
      ports:
        - "9092:9092"
        - "2181:2181"
      hostname: kafka
      expose:
        - "9092"
        - "2181"
      environment:
        TOPICS: test-topic
    redis:
      image: redis
      ports:
        - "6379"
      restart: always
    kafka-websocket-connector:
      build: ./kafka-websocket-connector
      image: andrewterra/kafka-websocket-connector
      ports:
        - "8077:8077"
      #   - "9092:9092"
      depends_on:
        - kafka
        - redis
      #   - zookeeper
      links:
        - kafka
        - redis
  </code></pre>