DirectorySecurity AdvisoriesPricing
/
Sign in
Directory
kafka logo

kafka

Last changed

Request a free trial

Contact our team to test out this image for free. Please also indicate any other images you would like to evaluate.

Tags
Overview
Comparison
Provenance
Specifications
SBOM
Vulnerabilities
Advisories

Chainguard Container for kafka

Apache Kafka distributed event store and stream-processing platform

Chainguard Containers are regularly-updated, secure-by-default container images.

Download this Container Image

For those with access, this container image is available on cgr.dev:

docker pull cgr.dev/ORGANIZATION/kafka:latest

Be sure to replace the ORGANIZATION placeholder with the name used for your organization's private repository within the Chainguard Registry.

Usage

This image uses the same entrypoint as apache/kafka and supports configuration via KAFKA_* environment variables.

SettingValue

Entrypoint

/__cacert_entrypoint.sh

Cmd

/etc/kafka/docker/run

User

appuser (uid 1000)

Working Directory

/

JAVA_HOME

/opt/java/openjdk

Key features:

  • KRaft Mode: Uses Kafka Raft metadata exclusively. ZooKeeper is not supported.
  • Environment Variable Configuration: Configure Kafka using KAFKA_* environment variables (e.g., KAFKA_NODE_ID, KAFKA_PROCESS_ROLES).
  • Automatic Configuration: Includes /etc/kafka/docker/run and related scripts for automatic configuration.
  • Non-Root User: Runs as appuser (uid 1000) matching apache/kafka.

Getting Started with Docker

Quick Start (Single Node)

Start a single-node Kafka broker in KRaft mode:

docker run -d \
  --name kafka \
  -p 9092:9092 \
  -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 CLUSTER_ID=MkU3OEVBNTcwNTJENDM2Qk \
  cgr.dev/ORGANIZATION/kafka:latest

With TLS Encryption

For production deployments with TLS, you'll need to generate keystores and configure SSL listeners.

Step 1: Generate TLS Keystores
docker volume create kafka-tls

docker run --rm \
  --user 0:0 \
  --entrypoint sh \
  -v kafka-tls:/tls \
  cgr.dev/chainguard/jdk:latest-dev \
  -c '
    apk add mkcert openssl
    cd /tls

    mkcert -cert-file kafka.crt -key-file kafka.key localhost kafka

    openssl pkcs12 -export \
      -in kafka.crt -inkey kafka.key \
      -out kafka.keystore.p12 \
      -name kafka \
      -password pass:changeit

    cp "$(mkcert -CAROOT)/rootCA.pem" rootCA.pem
    keytool -import -trustcacerts -noprompt \
      -alias CARoot \
      -file rootCA.pem \
      -keystore kafka.truststore.p12 \
      -storepass changeit -storetype PKCS12

    chmod 640 kafka.keystore.p12 kafka.truststore.p12
    chown 1000:1000 kafka.keystore.p12 kafka.truststore.p12
  '
Step 2: Start Kafka with TLS
docker run -d \
  --name kafka \
  -p 9093:9093 \
  -v kafka-tls:/etc/kafka/secrets \
  -e KAFKA_NODE_ID=1 \
  -e KAFKA_PROCESS_ROLES=broker,controller \
  -e KAFKA_LISTENERS=SSL://:9093,CONTROLLER://:9094 \
  -e KAFKA_ADVERTISED_LISTENERS=SSL://localhost:9093 \
  -e KAFKA_CONTROLLER_LISTENER_NAMES=CONTROLLER \
  -e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,SSL:SSL \
  -e KAFKA_CONTROLLER_QUORUM_VOTERS=1@localhost:9094 \
  -e KAFKA_SSL_KEYSTORE_LOCATION=/etc/kafka/secrets/kafka.keystore.p12 \
  -e KAFKA_SSL_KEYSTORE_PASSWORD=changeit \
  -e KAFKA_SSL_TRUSTSTORE_LOCATION=/etc/kafka/secrets/kafka.truststore.p12 \
  -e KAFKA_SSL_TRUSTSTORE_PASSWORD=changeit \
  -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
  -e CLUSTER_ID=MkU3OEVBNTcwNTJENDM2Qk \
  cgr.dev/ORGANIZATION/kafka:latest

Using with Kubernetes

For production Kafka clusters, use a StatefulSet. The image supports the same configuration patterns as apache/kafka:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: kafka
spec:
  serviceName: kafka
  replicas: 3
  selector:
    matchLabels:
      app: kafka
  template:
    metadata:
      labels:
        app: kafka
    spec:
      containers:
        - name: kafka
          image: cgr.dev/ORGANIZATION/kafka:latest
          env:
            - name: KAFKA_NODE_ID
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: KAFKA_PROCESS_ROLES
              value: "broker,controller"
            # ... additional KAFKA_* environment variables

Environment Variables

Configuration is done via environment variables prefixed with KAFKA_. The variable name maps to Kafka configuration properties:

Environment VariableKafka Property

KAFKA_NODE_ID

node.id

KAFKA_PROCESS_ROLES

process.roles

KAFKA_LISTENERS

listeners

KAFKA_ADVERTISED_LISTENERS

advertised.listeners

KAFKA_CONTROLLER_QUORUM_VOTERS

controller.quorum.voters

KAFKA_SSL_KEYSTORE_LOCATION

ssl.keystore.location

See the Apache Kafka documentation for all available configuration options.

Documentation and Resources

What are Chainguard Containers?

Chainguard's free tier of Starter container images are built with Wolfi, our minimal Linux undistro.

All other Chainguard Containers are built with Chainguard OS, Chainguard's minimal Linux operating system designed to produce container images that meet the requirements of a more secure software supply chain.

The main features of Chainguard Containers include:

For cases where you need container images with shells and package managers to build or debug, most Chainguard Containers come paired with a development, or -dev, variant.

In all other cases, including Chainguard Containers tagged as :latest or with a specific version number, the container images include only an open-source application and its runtime dependencies. These minimal container images typically do not contain a shell or package manager.

Although the -dev container image variants have similar security features as their more minimal versions, they include additional software that is typically not necessary in production environments. We recommend using multi-stage builds to copy artifacts from the -dev variant into a more minimal production image.

Need additional packages?

To improve security, Chainguard Containers include only essential dependencies. Need more packages? Chainguard customers can use Custom Assembly to add packages, either through the Console, chainctl, or API.

To use Custom Assembly in the Chainguard Console: navigate to the image you'd like to customize in your Organization's list of images, and click on the Customize image button at the top of the page.

Learn More

Refer to our Chainguard Containers documentation on Chainguard Academy. Chainguard also offers VMs and Librariescontact us for access.

Trademarks

This software listing is packaged by Chainguard. The trademarks set forth in this offering are owned by their respective companies, and use of them does not imply any affiliation, sponsorship, or endorsement by such companies.

Licenses

Chainguard's container images contain software packages that are direct or transitive dependencies. The following licenses were found in the "latest" tag of this image:

  • Apache-2.0

  • BSD-3-Clause

  • Bitstream-Vera

  • CC-PDDC

  • FTL

  • GCC-exception-3.1

  • GPL-2.0-only

For a complete list of licenses, please refer to this Image's SBOM.

Software license agreement

Compliance

Chainguard Containers are SLSA Level 3 compliant with detailed metadata and documentation about how it was built. We generate build provenance and a Software Bill of Materials (SBOM) for each release, with complete visibility into the software supply chain.

SLSA compliance at Chainguard

This image helps reduce time and effort in establishing PCI DSS 4.0 compliance with low-to-no CVEs.

PCI DSS at Chainguard

Related images
kafka-iamguarded logo
kafka-iamguarded

Category
Application

The trusted source for open source

Talk to an expert
© 2025 Chainguard. All Rights Reserved.
PrivacyTerms

Product

Chainguard ContainersChainguard LibrariesChainguard VMsIntegrationsPricing