📅  最后修改于: 2023-12-03 15:02:28.862000             🧑  作者: Mango
Kafka is a distributed streaming platform that is used for building real-time data pipelines and streaming applications. Docker is a popular containerization platform and Confluent provides a complete, scalable, and reliable platform to build real-time streaming data applications.
To use Kafka with Docker, one can either use the official Kafka images on Docker Hub or use the Confluent Platform images provided by Confluent.
The official Kafka images on Docker Hub can be used to run a single-node Kafka cluster or a multi-node Kafka cluster with ZooKeeper. Here is an example command to run a single-node Kafka cluster:
docker run -d --name my-kafka \
-p 9092:9092 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 \
confluentinc/cp-kafka:latest
Here my-kafka
is the name of the Docker container, 9092
is the port used by Kafka, and KAFKA_ADVERTISED_LISTENERS
specifies the hostname and port that other Kafka clients can use to connect to Kafka.
Confluent Platform provides a Docker image for each component of the platform, including Kafka, Schema Registry, Connect, and KSQL. The Confluent Platform images can be used to run a complete Kafka cluster with all the necessary components.
Here is an example command to run a multi-node Kafka cluster with Confluent Platform:
docker-compose up
This command will start a Kafka cluster with three brokers, ZooKeeper, Schema Registry, and KSQL, all running in separate Docker containers.
Using Kafka with Docker and Confluent Platform provides a convenient and scalable solution for building real-time streaming data applications. With the easy-to-use Docker images, it is easy to set up and run a complete Kafka cluster with all the necessary components.