This is an automated email from the ASF dual-hosted git repository.
clolov pushed a commit to branch 4.2
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/4.2 by this push:
new 62fc728cbe7 KAFKA-20093 Do not set KAFKA_URL as ENV in Docker (#21362)
62fc728cbe7 is described below
commit 62fc728cbe73fe790826b69741951557cde7416b
Author: Christo Lolov <[email protected]>
AuthorDate: Mon Jan 26 18:47:21 2026 +0000
KAFKA-20093 Do not set KAFKA_URL as ENV in Docker (#21362)
When creating a JVM Docker image for Kafka, due to recent(ish) changes
in the Dockerfile, we set KAFKA_URL as an environment variable. This
bakes the environment variable within the Docker image itself. In turn,
this causes a faulty server.properties to be generated, which only
contains a url=<URL> entry.
This PR reverts to using an ARG.
Building the Docker image locally and starting a container from it using
https://hub.docker.com/r/apache/kafka#quick-start no longer exhibits the
ENV.
Reviewers: Chia-Ping Tsai <[email protected]>
---
docker/jvm/Dockerfile | 16 ++++++----------
docker/native/Dockerfile | 7 +++----
2 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/docker/jvm/Dockerfile b/docker/jvm/Dockerfile
index 8d758ba50f1..6d65b2c41c9 100644
--- a/docker/jvm/Dockerfile
+++ b/docker/jvm/Dockerfile
@@ -23,8 +23,6 @@ USER root
# Get kafka from https://archive.apache.org/dist/kafka and pass the url
through build arguments
ARG kafka_url
-ENV KAFKA_URL=$kafka_url
-
COPY jsa_launch /etc/kafka/docker/jsa_launch
COPY server.properties /etc/kafka/docker/server.properties
@@ -35,10 +33,10 @@ RUN set -eux ; \
apk upgrade ; \
apk add --no-cache bash; \
mkdir opt/kafka; \
- if [ -n "$KAFKA_URL" ]; then \
+ if [ -n "$kafka_url" ]; then \
apk add --no-cache wget gcompat gpg gpg-agent procps; \
- wget -nv -O kafka.tgz "$KAFKA_URL"; \
- wget -nv -O kafka.tgz.asc "$KAFKA_URL.asc"; \
+ wget -nv -O kafka.tgz "$kafka_url"; \
+ wget -nv -O kafka.tgz.asc "$kafka_url.asc"; \
wget -nv -O KEYS https://downloads.apache.org/kafka/KEYS; \
tar xfz kafka.tgz -C opt/kafka --strip-components 1; \
gpg --import KEYS; \
@@ -62,8 +60,6 @@ USER root
ARG kafka_url
ARG build_date
-ENV KAFKA_URL=$kafka_url
-
COPY *kafka.tgz kafka.tgz
LABEL org.label-schema.name="kafka" \
@@ -77,10 +73,10 @@ RUN mkdir opt/kafka; \
apk update ; \
apk upgrade ; \
apk add --no-cache bash; \
- if [ -n "$KAFKA_URL" ]; then \
+ if [ -n "$kafka_url" ]; then \
apk add --no-cache wget gcompat gpg gpg-agent procps; \
- wget -nv -O kafka.tgz "$KAFKA_URL"; \
- wget -nv -O kafka.tgz.asc "$KAFKA_URL.asc"; \
+ wget -nv -O kafka.tgz "$kafka_url"; \
+ wget -nv -O kafka.tgz.asc "$kafka_url.asc"; \
tar xfz kafka.tgz -C /opt/kafka --strip-components 1; \
wget -nv -O KEYS https://downloads.apache.org/kafka/KEYS; \
gpg --import KEYS; \
diff --git a/docker/native/Dockerfile b/docker/native/Dockerfile
index d458dab72ce..1a574397cfe 100644
--- a/docker/native/Dockerfile
+++ b/docker/native/Dockerfile
@@ -19,7 +19,6 @@ ARG kafka_url
WORKDIR /app
-ENV KAFKA_URL=$kafka_url
ENV NATIVE_IMAGE_PATH="native-image"
ENV KAFKA_DIR="/app/kafka"
ENV NATIVE_CONFIGS_DIR="/app/native-image-configs"
@@ -31,10 +30,10 @@ COPY native_command.sh native_command.sh
COPY *kafka.tgz /app
-RUN if [ -n "$KAFKA_URL" ]; then \
+RUN if [ -n "$kafka_url" ]; then \
microdnf install wget; \
- wget -nv -O kafka.tgz "$KAFKA_URL"; \
- wget -nv -O kafka.tgz.asc "$KAFKA_URL.asc"; \
+ wget -nv -O kafka.tgz "$kafka_url"; \
+ wget -nv -O kafka.tgz.asc "$kafka_url.asc"; \
wget -nv -O KEYS https://downloads.apache.org/kafka/KEYS; \
gpg --import KEYS; \
gpg --batch --verify kafka.tgz.asc kafka.tgz; \