4a58b092
227.8 MB
4 months ago
27M
Name
Layer
Last update
11 months ago
5 months ago
4 months ago
5 months ago
11 months ago
11 months ago
11 months ago
5 months ago
11 months ago
5 months ago
11 months ago
11 months ago
11 months ago
11 months ago
Readme

kafkacat Docker image

kafkacat is a commandline tool for interacting with Kafka brokers. It can be used to produce and consume messages, as well as query metadata.

The docker image for kafkacat would typically be used in conjunction with Kafka running in a docker environment. The important thing is to understand the networking context of the docker container and the associated Kafka broker to which kafkacat is to connect.

The below examples show how to use the kafkacat Docker image. For general reference on usage of kafkacat see here.

Listing topics on a broker

Assuming your Kafka broker is accessible as kafka:29092 on the Docker network docker-compose_default, you can list topics by running:

docker run --tty \
           --network docker-compose_default \
           confluentinc/cp-kafkacat \
           kafkacat -b kafka:29092 \
                    -L

Consuming messages from a topic

Assuming your Kafka broker is accessible as kafka:29092 on the Docker network docker-compose_default, you can print messages and their associated metadata from topic foo, as follows:

docker run --tty \
           --network docker-compose_default \
           confluentinc/cp-kafkacat \
           kafkacat -b kafka:29092 -C -K: \
                    -f '\nKey (%K bytes): %k\t\nValue (%S bytes): %s\n\Partition: %p\tOffset: %o\n--\n' \
                    -t foo

Producing messages from a file on the host machine

kafkacat can produce messages into Kafka from a flat file. Assuming you have a file called /tmp/my_msgs.txt on the host machine from which you're running Docker, you would run the following to have kafkacat send these messages to the broker accessible as kafka:29092 on the Docker network docker-compose_default:

docker run --network docker-compose_default \
           --volume /tmp/my_msgs.txt:/data/my_msgs.txt \
           confluentinc/cp-kafkacat \
           kafkacat -b kafka:29092 \
                    -t my_msgs \
                    -P -l /data/my_msgs.txt

Producing messages inline from a script

This will send two messages, key/value 1/FOO and 2/BAR respectively. It assumes that your Kafka broker is accessible as kafka:29092 on the Docker network docker-compose_default.

docker run --interactive \
           --network docker-compose_default \
           confluentinc/cp-kafkacat \
            kafkacat -b kafka:29092 \
                    -t test \
                    -K: \
                    -P <<EOF
1:FOO
2:BAR
EOF

License

This Docker image is licensed under the Apache 2 license. For more information on the licenses for each of the individual Confluent Platform components packaged in this image, please refer to the respective Confluent Platform documentation.