Search code examples
dockerapache-kafka

Create a topic in docker apache/kafka


I'm following this guide https://kafka.apache.org/quickstart to run kafka locally using docker. On step 2 I run

docker pull apache/kafka:3.7.0
docker run -p 9092:9092 apache/kafka:3.7.0

Then, on step 3, I login into the container using Docker Desktop and run

bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server localhost:9092

But get an error /bin/sh: bin/kafka-topics.sh: not found. What am I doing wrong. Or there is some error in the manual?


Solution

  • I checked the source code of the Dockerfile, and the correct bin directory is /opt/kafka/bin

    So you could either give the absolute path of the script, or do docker run -w /opt/kafka ... to set the working directory.

    Ideally, those scripts would be on the PATH, as they are with other kafka images