Mike Hawkins
Mike Hawkins

Reputation: 2314

How do I create a topic in a running container instance of spotif/kafka from bash

I have Kafka running as a container, and i want to create a topic.

When i attempt the following command:

docker exec -it [container_id] /bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

I receive the following error:

OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "exec: \"/bin/kafka-topics.sh\": stat /bin/kafka-topics.sh: no such file or directory": unknown

How can i accomplish the creation of a topic?

Upvotes: 4

Views: 2838

Answers (1)

Mickael Maison
Mickael Maison

Reputation: 26885

It's because the kafka-topics.sh tool is not in /bin!

A quick look at the Dockerfile shows it's under /opt/kafka_2.11-0.10.1.0

Try:

docker exec -it [container_id] /opt/kafka_2.11-0.10.1.0/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

Upvotes: 7

Related Questions