title: how do i add a topic to a running kafka container using docker commands?
body: <p>I have a kafka container started using following </p>
  
  <pre><code>docker run --detach --name kafka -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=192.168.1.89 --env ADVERVTISED_PORT=9092 --env AUTO.CREATE.TOPICS.ENABLE spotify/kafka
  </code></pre>
  
  <p>i can use docker logs kafka to see its started.</p>
  
  <p>I then created a simple groovy script client producer to write some entries, however this keeps erroring with </p>
  
  <pre><code>&gt; Sending metadata request {topics=[wills topic]} to node 0
  &gt; Error while fetching metadata with correlation id 1 : {wills topic=INVALID_TOPIC_EXCEPTION}
  ....
  </code></pre>
  
  <p>I have set the following properties in the client code </p>
  
  <pre><code>    Properties props = new Properties()
      props.put("bootstrap.servers", "192.168.1.89:9092" )   //Assign localhost id and external port (9092 int)
      props.put("acks", "all")                            //Set acknowledgements for producer requests.
      props.put("retries", 0)                             //If the request fails, the producer can automatically retry,
      props.put("batch.size", 16384)                      //Specify buffer size in config
      props.put("linger.ms", 1)                           //Reduce the no of requests less than 0
      props.put("buffer.memory", 33554432)                //The buffer.memory controls the total amount of memory available to the producer for buffering.
      props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer")
      props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer")
      props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer")
      props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer")
      props.put ("auto.create.topics.enable", true)       //enable auto topic creation
  
      producer = new org.apache.kafka.clients.producer.KafkaProducer&lt;String, String&gt;(props)
  
      for(int i = 0; i &lt; 10; i++) {
          producer.send(new ProducerRecord&lt;String, String&gt;(topicName, Integer.toString(i), Integer.toString(i)))
      }
      println("Message sent successfully")
      producer.close()
  </code></pre>
  
  <p>but that does not not seem to enable auto topic creation. Given that i've spun the kafka server up as docker container - how does one administer that container instance once it is up and running using docker commands as the means to talk to the container </p>
  
  <p>there is a note on the kafka site along the line of running a shell commend "bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test" </p>
  
  <p>but its not easy to  see how one edits/interacts with this in container once its up.</p>
  
  <p>how does one administer the kafka container instance in docker once it has been started.  otherwise what to you have to add to the docker run command to get topics pre created at startup </p>
  
  <p>Advice greatfully received at this point </p>