专属域名
文档搜索
轩辕助手
Run助手
邀请有礼
返回顶部
快速返回页面顶部
收起
收起工具栏
轩辕镜像 官方专业版
轩辕镜像 官方专业版轩辕镜像 官方专业版官方专业版
首页个人中心搜索镜像

交易
充值流量我的订单
工具
提交工单镜像收录一键安装
Npm 源Pip 源Homebrew 源
帮助
常见问题
其他
关于我们网站地图

官方QQ群: 1072982923

apache/kafka Docker 镜像 - 轩辕镜像 | Docker 镜像高效稳定拉取服务

热门搜索:openclaw🔥nginx🔥redis🔥mysqlopenjdkcursorweb2apimemgraphzabbixetcdubuntucorednsjdk
kafka
apache/kafka
Apache 软件基金会镜像
Apache Kafka是一个开源的分布式流处理平台,旨在提供高吞吐量、低延迟的实时数据流传递服务,支持发布/订阅消息模式,能够持久化存储海量数据流并确保数据可靠性,具备水平扩展能力和容错机制,广泛应用于日志收集、事件驱动架构、实时数据集成及流处理系统等场景,为企业级应用提供高效、稳定的数据流传输与处理解决方案。
198 次收藏下载次数: 0状态:社区镜像维护者:Apache 软件基金会镜像仓库类型:镜像最近更新:14 天前
轩辕镜像,让镜像更快,让人生更轻。点击查看
版本下载
轩辕镜像,让镜像更快,让人生更轻。点击查看

Apache Kafka®

What is Apache Kafka?

Apache Kafka is an open-source event streaming platform used to collect, process, store, and integrate data at scale in real time. It powers numerous use cases including stream processing, data integration, and pub/sub messaging.

Kafka was originally developed at LinkedIn, was open sourced in 2011, and became an Apache Software Foundation project in 2012. It is used by thousands of organizations globally to power mission-critical real-time applications, from stock exchanges, to e-commerce applications, to IoT monitoring & analytics, to name a few.

Quick start

Start a Kafka broker:

console
docker run -d --name broker apache/kafka:latest

Open a shell in the broker container:

console
docker exec --workdir /opt/kafka/bin/ -it broker sh

A topic is a logical grouping of events in Kafka. From inside the container, create a topic called test-topic:

console
./kafka-topics.sh --bootstrap-server localhost:9092 --create --topic test-topic

Write two string events into the test-topic topic using the console producer that ships with Kafka:

console
./kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test-topic

This command will wait for input at a > prompt. Enter hello, press Enter, then world, and press Enter again. Enter Ctrl+C to exit the console producer.

Now read the events in the test-topic topic from the beginning of the log:

console
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test-topic --from-beginning

You will see the two strings that you previously produced:

hello
world

The consumer will continue to run until you exit out of it by entering Ctrl+C.

When you are finished, stop and remove the container by running the following command on your host machine:

console
docker rm -f broker

Overriding the default broker configuration

Apache Kafka supports a broad set of broker configurations that you may override via environment variables. The environment variables must begin with KAFKA_, and any dots in broker configurations should be specified as underscores in the corresponding environment variable. For example, to set the default number of partitions in topics, num.partitions, set the environment variable KAFKA_NUM_PARTITIONS. See the Kafka Docker Image Usage Guide for more information on overriding broker configuration in Docker.

It's important to note that if you are overriding any configuration, then none of the default configurations will be used. For example, to run Kafka in KRaft combined mode (meaning that the broker handling client requests and the controller handling cluster coordination both run in the same container) and set the default number of topic partitions to 3 instead of the default 1, we would specify KAFKA_NUM_PARTITIONS in addition to other required configurations:

console
docker run -d  \
  --name broker \
  -e KAFKA_NODE_ID=1 \
  -e KAFKA_PROCESS_ROLES=broker,controller \
  -e KAFKA_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093 \
  -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 \
  -e KAFKA_CONTROLLER_LISTENER_NAMES=CONTROLLER \
  -e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT \
  -e KAFKA_CONTROLLER_QUORUM_VOTERS=1@localhost:9093 \
  -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
  -e KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR=1 \
  -e KAFKA_TRANSACTION_STATE_LOG_MIN_ISR=1 \
  -e KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS=0 \
  -e KAFKA_NUM_PARTITIONS=3 \
  apache/kafka:latest

Specifying this many environment variables on the command line gets cumbersome. It's simpler to instead use Docker Compose to specify and manage Kafka in Docker. Depending on how you installed Docker, you may already have Docker Compose. You can verify that it's available by checking if this command succeeds, and refer to the Docker Compose installation documentation here if it doesn't:

console
docker compose version

To run Kafka with Docker Compose and override the default number of topic partitions to be 3, first copy the following into a file named docker-compose.yml:

yaml
services:
  broker:
    image: apache/kafka:latest
    container_name: broker
    environment:
      KAFKA_NODE_ID: 1
      KAFKA_PROCESS_ROLES: broker,controller
      KAFKA_LISTENERS: PLAINTEXT://localhost:9092,CONTROLLER://localhost:9093
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
      KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
      KAFKA_CONTROLLER_QUORUM_VOTERS: 1@localhost:9093
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
      KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
      KAFKA_NUM_PARTITIONS: 3

Now, from the directory containing this file, bring Kafka up in detached mode so that the containers run in the background:

console
docker compose up -d

The above quick start steps will work if you'd like to test topic creation and producing / consuming messages.

When you are finished, stop and remove the container by running the following command on your host machine from the directory containing the docker-compose.yml file:

console
docker compose down

External clients

The examples up to this point run Kafka client commands from within Docker. In order to run clients from outside Docker, two additional steps are needed when running one container in combined mode (it gets a little more complicated in the next section on multiple brokers).

First, map the port that Kafka listens on to the same port on your host machine, either by passing -p 9092:9092 to the docker run command:

console
docker run -d -p 9092:9092 --name broker apache/kafka:latest

Or, if using Docker Compose, add the port mapping to the broker container spec:

yaml
ports:
  - 9092:9092

Second, download and unzip the latest Kafka release. The console producer and consumer CLI tools are included in the unzipped distribution's bin directory. The above quick start steps will work from your host machine; it's just that localhost refers to your host machine as opposed to the within-container localhost.

Multiple nodes

In this section, you will explore a more realistic Kafka deployment consisting of three brokers and three controllers running in their own containers (i.e., KRaft isolated mode). We'll also configure it such that we can connect to Kafka from within Docker or from the host machine. Bear in mind that doing this exercise in Docker is convenient to learn about multi-broker configurations and the Kafka protocol, but this Docker Compose example isn't appropriate for a production deployment.

Compared to a single-node Kafka deployment, there is a bit more to do on the configuration front:

  1. KAFKA_PROCESS_ROLES is either broker or controller depending on the container's role, not the KRaft combined mode value broker,controller
  2. KAFKA_CONTROLLER_QUORUM_VOTERS is a comma-separated list of the three controllers
  3. We accept the default values for KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR (3), KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR (3), and KAFKA_TRANSACTION_STATE_LOG_MIN_ISR (2) now that there are enough brokers to support the default settings, so we don't specify these configurations (a partition's replicas must reside on different brokers for fault tolerance)
  4. Brokers have two listeners: one for communicating within the Docker network and one for connecting from the host machine. Because Kafka clients connect directly to brokers after initially connecting (bootstrapping), one listener uses the container name because it is a resolvable name for all containers on the Docker network. This listener is also used for inter-broker communication. The second listener uses localhost on a unique port that gets mapped on the host (29092 for broker-1, 39092 for broker-2, and 49092 for broker-3). With one node, a single listener on localhost works because the localhost name is conveniently correct from within the container and from the host machine, but this doesn't apply in a multi-node setup.

To deploy this six-node setup on your machine, copy the following into a file named docker-compose.yml:

yaml
services:
  controller-1:
    image: apache/kafka:latest
    container_name: controller-1
    environment:
      KAFKA_NODE_ID: 1
      KAFKA_PROCESS_ROLES: controller
      KAFKA_LISTENERS: CONTROLLER://:9093
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_CONTROLLER_QUORUM_VOTERS: 1@controller-1:9093,2@controller-2:9093,3@controller-3:9093
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0

  controller-2:
    image: apache/kafka:latest
    container_name: controller-2
    environment:
      KAFKA_NODE_ID: 2
      KAFKA_PROCESS_ROLES: controller
      KAFKA_LISTENERS: CONTROLLER://:9093
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_CONTROLLER_QUORUM_VOTERS: 1@controller-1:9093,2@controller-2:9093,3@controller-3:9093
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0

  controller-3:
    image: apache/kafka:latest
    container_name: controller-3
    environment:
      KAFKA_NODE_ID: 3
      KAFKA_PROCESS_ROLES: controller
      KAFKA_LISTENERS: CONTROLLER://:9093
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_CONTROLLER_QUORUM_VOTERS: 1@controller-1:9093,2@controller-2:9093,3@controller-3:9093
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0

  broker-1:
    image: apache/kafka:latest
    container_name: broker-1
    ports:
      - 29092:9092
    environment:
      KAFKA_NODE_ID: 4
      KAFKA_PROCESS_ROLES: broker
      KAFKA_LISTENERS: 'PLAINTEXT://:***,PLAINTEXT_HOST://:9092'
      KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://broker-1:***,PLAINTEXT_HOST://localhost:29092'
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_CONTROLLER_QUORUM_VOTERS: 1@controller-1:9093,2@controller-2:9093,3@controller-3:9093
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
    depends_on:
      - controller-1
      - controller-2
      - controller-3

  broker-2:
    image: apache/kafka:latest
    container_name: broker-2
    ports:
      - 39092:9092
    environment:
      KAFKA_NODE_ID: 5
      KAFKA_PROCESS_ROLES: broker
      KAFKA_LISTENERS: 'PLAINTEXT://:***,PLAINTEXT_HOST://:9092'
      KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://broker-2:***,PLAINTEXT_HOST://localhost:39092'
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_CONTROLLER_QUORUM_VOTERS: 1@controller-1:9093,2@controller-2:9093,3@controller-3:9093
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
    depends_on:
      - controller-1
      - controller-2
      - controller-3

  broker-3:
    image: apache/kafka:latest
    container_name: broker-3
    ports:
      - 49092:9092
    environment:
      KAFKA_NODE_ID: 6
      KAFKA_PROCESS_ROLES: broker
      KAFKA_LISTENERS: 'PLAINTEXT://:***,PLAINTEXT_HOST://:9092'
      KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://broker-3:***,PLAINTEXT_HOST://localhost:49092'
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_CONTROLLER_QUORUM_VOTERS: 1@controller-1:9093,2@controller-2:9093,3@controller-3:9093
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
    depends_on:
      - controller-1
      - controller-2
      - controller-3

Start the containers from the directory containing the docker-compose.yml file:

console
docker compose up -d

Now, the following commands will work to produce and consume from within the Docker network. First, open a shell on any of the nodes:

console
docker exec --workdir /opt/kafka/bin/ -it broker-1 sh

Now run these commands in the container shell to create a topic, produce to it, and consume from it:

console
./kafka-topics.sh --bootstrap-server broker-1:***,broker-2:***,broker-3:*** --create --topic test-topic
console
./kafka-console-consumer.sh --bootstrap-server broker-1:***,broker-2:***,broker-3:*** --topic test-topic --from-beginning
console
./kafka-console-producer.sh --bootstrap-server broker-1:***,broker-2:***,broker-3:*** --topic test-topic

Alternatively, you can run the client programs from your host machine by navigating to your Kafka distribution's bin directory and running:

console
./kafka-topics.sh --bootstrap-server localhost:29092,localhost:39092,localhost:49092 --create --topic test-topic2
console
./kafka-console-producer.sh --bootstrap-server localhost:29092,localhost:39092,localhost:49092 --topic test-topic2
console
./kafka-console-consumer.sh --bootstrap-server localhost:29092,localhost:39092,localhost:49092 --topic test-topic2 --from-beginning

When you are finished, stop and remove the Kafka deployment by running the following command on your host machine from the directory containing the docker-compose.yml file:

console
docker compose down

Additional resources

  • Apache Kafka documentation
  • Introduction to Kafka Streams, Apache Kafka's library for developing stream processing applications on the JVM
  • Introduction to Kafka Connect, Apache Kafka's framework for configuration-based connectors to move data from external systems into Kafka (source connectors) or from Kafka into external systems (sink connectors)
  • Books and papers on Kafka and streaming in general
  • Slides and recordings of conference talks on streaming

Deployment & Usage Documentation

Apache Kafka Docker 容器化部署指南

Apache Kafka是一个开源的分布式事件流平台,旨在高吞吐量、低延迟地处理实时数据流。它最初由LinkedIn开发,2011年开源,2012年成为Apache Software Foundation顶级项目。Kafka广泛应用于流处理、数据集成、发布/订阅消息传递等场景,全球数千家组织使用它来支持关键业务的实时应用。

Read More
查看更多 kafka 相关镜像 →
bitnami/kafka logo
bitnami/kafka
bitnami
比特纳米Kafka安全镜像是一款针对分布式流处理平台Kafka的预配置、安全加固容器镜像,集成行业最佳安全实践,涵盖漏洞扫描、最小权限原则、加密通信支持及合规性检查,旨在简化Kafka部署流程,确保数据传输与存储安全性,适用于企业级流数据处理场景,帮助用户快速搭建安全可靠的Kafka集群。
956 次收藏1亿+ 次下载
6 个月前更新
bitnamicharts/kafka logo
bitnamicharts/kafka
bitnamicharts
Bitnami为Apache Kafka提供的Helm Chart是一款预配置的Kubernetes包管理工具,旨在简化分布式流处理平台Apache Kafka在Kubernetes集群中的部署、配置与全生命周期运维管理,集成了高可用性集群设置、安全认证机制、Prometheus监控指标及自动伸缩策略等核心功能,帮助用户无需手动处理复杂的集群参数配置,即可快速搭建稳定、可扩展且符合生产级标准的Kafka服务,适用于从开发测试到大规模生产环境的各类场景。
4 次收藏1000万+ 次下载
6 个月前更新
ubuntu/kafka logo
ubuntu/kafka
Ubuntu 官方镜像
Apache Kafka 是一个分布式事件流平台,它支持高吞吐量、低延迟的实时数据流处理与传输,可广泛应用于消息传递、日志聚合、实时分析、数据集成等场景,其长期维护轨道由 Canonical 负责,以确保平台在稳定性、安全性及功能迭代方面获得持续支持,为企业级用户提供可靠的事件流处理解决方案。
60 次收藏100万+ 次下载
1 个月前更新
manageiq/kafka logo
manageiq/kafka
manageiq
Kafka container for ManageIQ
1万+ 次下载
7 年前更新
adobe/kafka logo
adobe/kafka
adobe
暂无描述
5.5千+ 次下载
5 个月前更新
rancher/kafka logo
rancher/kafka
rancher
暂无描述
2 次收藏4.1千+ 次下载
9 年前更新

轩辕镜像配置手册

探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式

Docker 配置

登录仓库拉取

通过 Docker 登录认证访问私有仓库

专属域名拉取

无需登录使用专属域名

K8s Containerd

Kubernetes 集群配置 Containerd

K3s

K3s 轻量级 Kubernetes 镜像加速

Dev Containers

VS Code Dev Containers 配置

Podman

Podman 容器引擎配置

Singularity/Apptainer

HPC 科学计算容器配置

其他仓库配置

ghcr、Quay、nvcr 等镜像仓库

系统配置

Linux

在 Linux 系统配置镜像服务

Windows/Mac

在 Docker Desktop 配置镜像

MacOS OrbStack

MacOS OrbStack 容器配置

Docker Compose

Docker Compose 项目配置

NAS 设备

群晖

Synology 群晖 NAS 配置

飞牛

飞牛 fnOS 系统配置镜像

绿联

绿联 NAS 系统配置镜像

威联通

QNAP 威联通 NAS 配置

极空间

极空间 NAS 系统配置服务

网络设备

爱快路由

爱快 iKuai 路由系统配置

宝塔面板

在宝塔面板一键配置镜像

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

使用与功能问题

docker search 报错:专属域名下仅支持 Docker Hub 查询

docker search 报错问题

网页搜不到镜像:Docker Hub 有但轩辕镜像搜索无结果

镜像搜索不到

离线传输镜像:无法直连时用 docker save/load 迁移

离线传输镜像

Docker 插件安装错误:application/vnd.docker.plugin.v1+json

Docker 插件安装错误

WSL 下 Docker 拉取慢:网络与挂载目录影响及优化

WSL 拉取镜像慢

轩辕镜像是否安全?镜像完整性校验(digest)说明

镜像安全性

如何用轩辕镜像拉取镜像?登录方式与专属域名配置

如何拉取镜像

错误码与失败问题

manifest unknown 错误:镜像不存在或标签错误

manifest unknown 错误

TLS/SSL 证书验证失败:Docker pull 时 HTTPS 证书错误

TLS 证书验证失败

DNS 解析超时:无法解析镜像仓库地址或连接超时

DNS 解析超时

410 Gone 错误:Docker 版本过低导致协议不兼容

410 错误:版本过低

402 Payment Required 错误:流量耗尽错误提示

402 错误:流量耗尽

401 UNAUTHORIZED 错误:身份认证失败或登录信息错误

身份认证失败错误

429 Too Many Requests 错误:请求频率超出专业版限制

429 限流错误

Docker login 凭证保存错误:Cannot autolaunch D-Bus(不影响登录)

凭证保存错误

账号 / 计费 / 权限

免费版与专业版区别:功能、限额与使用场景对比

免费版与专业版区别

支持的镜像仓库:Docker Hub、GCR、GHCR、K8s 等列表

轩辕镜像支持的镜像仓库

拉取失败是否扣流量?计费规则说明

拉取失败流量计费

KYSEC 权限不够:麒麟 V10/统信 UOS 下脚本执行被拦截

KYSEC 权限错误

如何申请开具发票?(增值税普票/专票)

开具发票

如何修改网站与仓库登录密码?

修改网站和仓库密码

配置与原理类

registry-mirrors 未生效:仍访问官方仓库或报错的原因

registry-mirrors 未生效

如何去掉镜像名称中的轩辕域名前缀?(docker tag)

去掉域名前缀

如何拉取指定架构镜像?(ARM64/AMD64 等多架构)

拉取指定架构镜像

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
Apache 软件基金会镜像
...
apache/kafka
博客公告Docker 镜像公告与技术博客
热门镜像查看热门 Docker 镜像推荐
一键安装一键安装 Docker 并配置镜像源
镜像拉取问题咨询请 提交工单,官方技术交流群:1072982923。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
镜像拉取问题咨询请提交工单,官方技术交流群:。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
官方邮箱:点击复制邮箱
©2024-2026 源码跳动
官方邮箱:点击复制邮箱Copyright © 2024-2026 杭州源码跳动科技有限公司. All rights reserved.