Environment:Apache Kafka Docker Build Environment
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Containerization |
| Last Updated | 2026-02-09 12:00 GMT |
Overview
Docker Engine with BuildX plugin for building multi-architecture (amd64/arm64) Kafka container images based on Eclipse Temurin 21 JRE Alpine.
Description
The Docker Build Environment provides the infrastructure to build, test, and publish Apache Kafka container images. It uses Docker BuildX for multi-architecture builds targeting `linux/amd64` and `linux/arm64`. The JVM-based image uses `eclipse-temurin:21-jre-alpine` as the base, while the native image uses `ghcr.io/graalvm/graalvm-community:21` for the build stage and `alpine:latest` for runtime. The build pipeline includes a JSA (Java Shared Archive) generation stage using dynamic CDS for faster startup. Python scripts in `docker/` orchestrate the build and test processes, requiring `requests` and `HTMLTestRunner-Python3`.
Usage
Use this environment for the Docker Image Release workflow, including building local test images, running multi-architecture builds, and pushing to container registries (Docker Hub, etc.).
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux (recommended), macOS | BuildX multi-arch builds work best on Linux |
| Docker | Docker Engine with BuildX plugin | Required for `docker buildx create` and `docker buildx build` |
| Python | Python 3.x | Required for build orchestration scripts |
| Network | Internet access | For pulling base images and pushing to registry |
| Disk | 5GB+ free space | Docker images and build cache |
Dependencies
System Packages
- `docker` with BuildX plugin
- `python3`
Python Packages
- `requests`
- `HTMLTestRunner-Python3`
Docker Base Images
- `eclipse-temurin:21-jre-alpine` (JVM images)
- `ghcr.io/graalvm/graalvm-community:21` (Native build stage)
- `alpine:latest` (Native runtime stage)
Credentials
The following credentials must be available for publishing:
- Docker Registry Login: Must be logged into the target Docker registry before running `docker_release.py`.
- Docker Hub Token: For pushing to `apache/kafka` on Docker Hub (or equivalent registry).
Quick Install
# Install Python dependencies for Docker build scripts
pip install requests HTMLTestRunner-Python3
# Verify Docker and BuildX
docker --version
docker buildx version
# Build and test a local image
python docker/docker_build_test.py
Code Evidence
Multi-architecture build from `docker/docker_release.py:43-57`:
def build_push(image, tag, kafka_url):
command = f"docker buildx build --platform linux/amd64,linux/arm64 " \
f"--build-arg kafka_url={kafka_url} " \
f"--build-arg build_date={datetime.now()} " \
f"-t {image}:{tag} --push ."
Builder creation from `docker/docker_release.py:53-55`:
def create_builder():
command = "docker buildx create --name kafka-builder --use"
Docker base image from `docker/jvm/Dockerfile:19`:
FROM eclipse-temurin:21-jre-alpine AS build-jsa
JSA generation from `docker/jvm/Dockerfile:48-49`:
# Generate jsa files using dynamic CDS for kafka server start command and kafka storage format command
RUN /etc/kafka/docker/jsa_launch
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `docker buildx create: command not found` | BuildX plugin not installed | Install Docker BuildX plugin or upgrade Docker Desktop |
| `error: failed to solve: eclipse-temurin:21-jre-alpine: pull access denied` | Docker not logged in or rate limited | Run `docker login` or wait for rate limit reset |
| `ERROR: Multiple platforms not supported` | BuildX builder not using docker-container driver | Run `docker buildx create --name kafka-builder --driver docker-container --use` |
| `requests.exceptions.ConnectionError` | Network issue during test | Ensure Docker daemon is running and network is available |
Compatibility Notes
- Linux vs macOS: Multi-architecture builds require QEMU emulation on non-Linux hosts; native performance only on Linux.
- Docker Desktop: BuildX is bundled; standalone Docker Engine may need separate BuildX installation.
- ARM64: Native arm64 builds require either arm64 host or QEMU binfmt registration.
- GraalVM Native: Native images only supported for specific platforms; requires `ghcr.io/graalvm/graalvm-community:21`.