From fe014eca6a7dd3b78dcf59fb498fc4df6c327754 Mon Sep 17 00:00:00 2001 From: rich7420 Date: Sun, 21 Dec 2025 19:49:58 +0800 Subject: [PATCH 1/7] Trim Ozone docker image size --- Dockerfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Dockerfile b/Dockerfile index f410a6d..d1cd511 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,4 +25,31 @@ RUN sudo rm -rf /opt/hadoop && curl -LSs -o ozone.tar.gz $OZONE_URL && tar zxf o WORKDIR /opt/hadoop +# Remove unnecessary files to reduce image size (HDDS-13426) +RUN sudo find . -type f \( \ + -name "ozone-filesystem-hadoop2-*.jar" -o \ + -name "ozone-filesystem-hadoop3-*.jar" -o \ + -name "ozone-filesystem-hadoop3-client-*.jar" -o \ + -name "*-tests.jar" -o \ + -name "*-test.jar" -o \ + -name "*test*.jar" -o \ + -name "*-docs-*.jar" -o \ + -name "*-shaded.jar" -o \ + -name "*-all.jar" -o \ + -name "*-fat.jar" -o \ + -name "*.class" -o \ + -name "*.pyc" -o \ + -name ".DS_Store" \ + \) -delete 2>/dev/null || true && \ + # Remove documentation, examples, and license files + sudo rm -rf docs examples share/doc share/man licenses \ + LICENSE.txt NOTICE.txt README.md HISTORY.md SECURITY.md CONTRIBUTING.md \ + compose kubernetes/examples share/ozone/byteman 2>/dev/null || true && \ + # Remove all markdown and text documentation files + sudo find . -type f \( -name "*.md" -o -name "*.txt" \) ! -path "*/etc/*" ! -path "*/bin/*" ! -path "*/sbin/*" ! -path "*/libexec/*" -delete 2>/dev/null || true && \ + # Remove test directories + sudo find . -type d \( -name "test*" -o -name "tests" -o -name "*test" \) -exec rm -rf {} + 2>/dev/null || true && \ + # Remove empty directories + sudo find . -type d -empty -delete 2>/dev/null || true + CMD ["echo","Please check https://github.com/apache/ozone-docker for information."] From e3c276a22b05810288bca98141e8b40d3d900bf4 Mon Sep 17 00:00:00 2001 From: rich7420 Date: Tue, 23 Dec 2025 10:21:59 +0800 Subject: [PATCH 2/7] update --- Dockerfile | 27 --------------------------- Dockerfile.slim | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 27 deletions(-) create mode 100644 Dockerfile.slim diff --git a/Dockerfile b/Dockerfile index d1cd511..f410a6d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,31 +25,4 @@ RUN sudo rm -rf /opt/hadoop && curl -LSs -o ozone.tar.gz $OZONE_URL && tar zxf o WORKDIR /opt/hadoop -# Remove unnecessary files to reduce image size (HDDS-13426) -RUN sudo find . -type f \( \ - -name "ozone-filesystem-hadoop2-*.jar" -o \ - -name "ozone-filesystem-hadoop3-*.jar" -o \ - -name "ozone-filesystem-hadoop3-client-*.jar" -o \ - -name "*-tests.jar" -o \ - -name "*-test.jar" -o \ - -name "*test*.jar" -o \ - -name "*-docs-*.jar" -o \ - -name "*-shaded.jar" -o \ - -name "*-all.jar" -o \ - -name "*-fat.jar" -o \ - -name "*.class" -o \ - -name "*.pyc" -o \ - -name ".DS_Store" \ - \) -delete 2>/dev/null || true && \ - # Remove documentation, examples, and license files - sudo rm -rf docs examples share/doc share/man licenses \ - LICENSE.txt NOTICE.txt README.md HISTORY.md SECURITY.md CONTRIBUTING.md \ - compose kubernetes/examples share/ozone/byteman 2>/dev/null || true && \ - # Remove all markdown and text documentation files - sudo find . -type f \( -name "*.md" -o -name "*.txt" \) ! -path "*/etc/*" ! -path "*/bin/*" ! -path "*/sbin/*" ! -path "*/libexec/*" -delete 2>/dev/null || true && \ - # Remove test directories - sudo find . -type d \( -name "test*" -o -name "tests" -o -name "*test" \) -exec rm -rf {} + 2>/dev/null || true && \ - # Remove empty directories - sudo find . -type d -empty -delete 2>/dev/null || true - CMD ["echo","Please check https://github.com/apache/ozone-docker for information."] diff --git a/Dockerfile.slim b/Dockerfile.slim new file mode 100644 index 0000000..1783b29 --- /dev/null +++ b/Dockerfile.slim @@ -0,0 +1,43 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG OZONE_RUNNER_IMAGE=apache/ozone-runner +ARG OZONE_RUNNER_VERSION=20250410-1-jdk21 +ARG OZONE_VERSION=2.0.0 +ARG OZONE_URL="https://www.apache.org/dyn/closer.lua?action=download&filename=ozone/${OZONE_VERSION}/ozone-${OZONE_VERSION}.tar.gz" + +FROM alpine:latest AS extractor +ARG OZONE_VERSION +ARG OZONE_URL + +WORKDIR /tmp +RUN apk add --no-cache curl tar && \ + curl -LSs -o ozone.tar.gz "$OZONE_URL" && \ + tar zxf ozone.tar.gz && \ + cd ozone-${OZONE_VERSION} && \ + rm -rf docs examples share/doc share/man licenses LICENSE.txt NOTICE.txt README.md HISTORY.md SECURITY.md CONTRIBUTING.md compose kubernetes share/ozone/byteman && \ + find . -type f \( -name "ozone-filesystem-hadoop2-*.jar" -o -name "ozone-filesystem-hadoop3-*.jar" -o -name "ozone-filesystem-hadoop3-client-*.jar" -o -name "*-tests.jar" -o -name "*-test.jar" -o -name "*test*.jar" -o -name "*-docs-*.jar" -o -name "*-shaded.jar" -o -name "*-all.jar" -o -name "*-fat.jar" \) -delete && \ + find . -type d \( -name "test*" -o -name "tests" -o -name "*test" -o -name "__pycache__" \) -exec rm -rf {} + 2>/dev/null || true && \ + find . -type f \( -name "*.md" -o -name "*.txt" -o -name "*.pyc" \) ! -path "*/etc/*" ! -path "*/bin/*" ! -path "*/sbin/*" ! -path "*/libexec/*" -delete 2>/dev/null || true + +FROM ${OZONE_RUNNER_IMAGE}:${OZONE_RUNNER_VERSION} +ARG OZONE_VERSION + +WORKDIR /opt +COPY --from=extractor /tmp/ozone-${OZONE_VERSION} hadoop + +WORKDIR /opt/hadoop + +CMD ["echo","Please check https://github.com/apache/ozone-docker for information."] From ea300aa940050df08968d6c05f2f5a429272a320 Mon Sep 17 00:00:00 2001 From: rich7420 Date: Tue, 23 Dec 2025 16:47:42 +0800 Subject: [PATCH 3/7] follow the suggestions --- Dockerfile.slim | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/Dockerfile.slim b/Dockerfile.slim index 1783b29..f7b3288 100644 --- a/Dockerfile.slim +++ b/Dockerfile.slim @@ -15,28 +15,40 @@ ARG OZONE_RUNNER_IMAGE=apache/ozone-runner ARG OZONE_RUNNER_VERSION=20250410-1-jdk21 +FROM ${OZONE_RUNNER_IMAGE}:${OZONE_RUNNER_VERSION} + ARG OZONE_VERSION=2.0.0 ARG OZONE_URL="https://www.apache.org/dyn/closer.lua?action=download&filename=ozone/${OZONE_VERSION}/ozone-${OZONE_VERSION}.tar.gz" -FROM alpine:latest AS extractor -ARG OZONE_VERSION -ARG OZONE_URL - -WORKDIR /tmp -RUN apk add --no-cache curl tar && \ - curl -LSs -o ozone.tar.gz "$OZONE_URL" && \ - tar zxf ozone.tar.gz && \ - cd ozone-${OZONE_VERSION} && \ - rm -rf docs examples share/doc share/man licenses LICENSE.txt NOTICE.txt README.md HISTORY.md SECURITY.md CONTRIBUTING.md compose kubernetes share/ozone/byteman && \ - find . -type f \( -name "ozone-filesystem-hadoop2-*.jar" -o -name "ozone-filesystem-hadoop3-*.jar" -o -name "ozone-filesystem-hadoop3-client-*.jar" -o -name "*-tests.jar" -o -name "*-test.jar" -o -name "*test*.jar" -o -name "*-docs-*.jar" -o -name "*-shaded.jar" -o -name "*-all.jar" -o -name "*-fat.jar" \) -delete && \ - find . -type d \( -name "test*" -o -name "tests" -o -name "*test" -o -name "__pycache__" \) -exec rm -rf {} + 2>/dev/null || true && \ - find . -type f \( -name "*.md" -o -name "*.txt" -o -name "*.pyc" \) ! -path "*/etc/*" ! -path "*/bin/*" ! -path "*/sbin/*" ! -path "*/libexec/*" -delete 2>/dev/null || true - -FROM ${OZONE_RUNNER_IMAGE}:${OZONE_RUNNER_VERSION} -ARG OZONE_VERSION - WORKDIR /opt -COPY --from=extractor /tmp/ozone-${OZONE_VERSION} hadoop +RUN sudo rm -rf /opt/hadoop && \ + curl -LSs -o ozone.tar.gz $OZONE_URL && \ + tar zxf ozone.tar.gz && \ + rm ozone.tar.gz && \ + mv ozone* hadoop && \ + cd hadoop && \ + sudo rm -rf \ + CONTRIBUTING.md \ + compose \ + docs \ + examples \ + HISTORY.md \ + kubernetes \ + README.md \ + SECURITY.md \ + share/doc \ + share/man \ + share/ozone/byteman \ + smoketest \ + tests && \ + sudo find . -type f \( \ + -name "*-all.jar" -o \ + -name "*-docs-*.jar" -o \ + -name "*-fat.jar" -o \ + -name "*-shaded.jar" -o \ + -name "*test*.jar" -o \ + -name "ozone-filesystem-hadoop*.jar" \ + \) -delete WORKDIR /opt/hadoop From c50c9f2bf9ebcaef0b285b09d82f3f84fcd9cd44 Mon Sep 17 00:00:00 2001 From: rich7420 Date: Thu, 25 Dec 2025 17:31:03 +0800 Subject: [PATCH 4/7] update --- Dockerfile | 31 ++++++++++++++++++++++++++-- Dockerfile.slim | 55 ------------------------------------------------- 2 files changed, 29 insertions(+), 57 deletions(-) delete mode 100644 Dockerfile.slim diff --git a/Dockerfile b/Dockerfile index f410a6d..01eee81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,14 +14,41 @@ # limitations under the License. ARG OZONE_RUNNER_IMAGE=apache/ozone-runner -ARG OZONE_RUNNER_VERSION=20250410-1-jdk21 +ARG OZONE_RUNNER_VERSION=20251225-1-jdk21-slim FROM ${OZONE_RUNNER_IMAGE}:${OZONE_RUNNER_VERSION} ARG OZONE_VERSION=2.0.0 ARG OZONE_URL="https://www.apache.org/dyn/closer.lua?action=download&filename=ozone/${OZONE_VERSION}/ozone-${OZONE_VERSION}.tar.gz" WORKDIR /opt -RUN sudo rm -rf /opt/hadoop && curl -LSs -o ozone.tar.gz $OZONE_URL && tar zxf ozone.tar.gz && rm ozone.tar.gz && mv ozone* hadoop +RUN sudo rm -rf /opt/hadoop && \ + curl -LSs -o ozone.tar.gz $OZONE_URL && \ + tar zxf ozone.tar.gz && \ + rm ozone.tar.gz && \ + mv ozone* hadoop && \ + cd hadoop && \ + sudo rm -rf \ + CONTRIBUTING.md \ + compose \ + docs \ + examples \ + HISTORY.md \ + kubernetes \ + README.md \ + SECURITY.md \ + share/doc \ + share/man \ + share/ozone/byteman \ + smoketest \ + tests && \ + sudo find . -type f \( \ + -name "*-all.jar" -o \ + -name "*-docs-*.jar" -o \ + -name "*-fat.jar" -o \ + -name "*-shaded.jar" -o \ + -name "*test*.jar" -o \ + -name "ozone-filesystem-hadoop*.jar" \ + \) -delete WORKDIR /opt/hadoop diff --git a/Dockerfile.slim b/Dockerfile.slim deleted file mode 100644 index f7b3288..0000000 --- a/Dockerfile.slim +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -ARG OZONE_RUNNER_IMAGE=apache/ozone-runner -ARG OZONE_RUNNER_VERSION=20250410-1-jdk21 -FROM ${OZONE_RUNNER_IMAGE}:${OZONE_RUNNER_VERSION} - -ARG OZONE_VERSION=2.0.0 -ARG OZONE_URL="https://www.apache.org/dyn/closer.lua?action=download&filename=ozone/${OZONE_VERSION}/ozone-${OZONE_VERSION}.tar.gz" - -WORKDIR /opt -RUN sudo rm -rf /opt/hadoop && \ - curl -LSs -o ozone.tar.gz $OZONE_URL && \ - tar zxf ozone.tar.gz && \ - rm ozone.tar.gz && \ - mv ozone* hadoop && \ - cd hadoop && \ - sudo rm -rf \ - CONTRIBUTING.md \ - compose \ - docs \ - examples \ - HISTORY.md \ - kubernetes \ - README.md \ - SECURITY.md \ - share/doc \ - share/man \ - share/ozone/byteman \ - smoketest \ - tests && \ - sudo find . -type f \( \ - -name "*-all.jar" -o \ - -name "*-docs-*.jar" -o \ - -name "*-fat.jar" -o \ - -name "*-shaded.jar" -o \ - -name "*test*.jar" -o \ - -name "ozone-filesystem-hadoop*.jar" \ - \) -delete - -WORKDIR /opt/hadoop - -CMD ["echo","Please check https://github.com/apache/ozone-docker for information."] From cad10a95a02554a31763d5b8fb050094e65c74e7 Mon Sep 17 00:00:00 2001 From: rich7420 Date: Thu, 25 Dec 2025 19:45:11 +0800 Subject: [PATCH 5/7] remove redundant part --- Dockerfile | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 01eee81..7aed461 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,19 +36,12 @@ RUN sudo rm -rf /opt/hadoop && \ kubernetes \ README.md \ SECURITY.md \ - share/doc \ - share/man \ share/ozone/byteman \ smoketest \ tests && \ - sudo find . -type f \( \ - -name "*-all.jar" -o \ - -name "*-docs-*.jar" -o \ - -name "*-fat.jar" -o \ - -name "*-shaded.jar" -o \ - -name "*test*.jar" -o \ - -name "ozone-filesystem-hadoop*.jar" \ - \) -delete + sudo rm -f \ + share/ozone/lib/*-docs-*.jar \ + share/ozone/lib/ozone-filesystem-hadoop*.jar WORKDIR /opt/hadoop From a939c1bb4c359683b281be3328f74afce66919c0 Mon Sep 17 00:00:00 2001 From: "Doroszlai, Attila" <6454655+adoroszlai@users.noreply.github.com> Date: Fri, 26 Dec 2025 07:58:39 +0100 Subject: [PATCH 6/7] Needs python, combine rm commands --- Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7aed461..a5aa71d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ # limitations under the License. ARG OZONE_RUNNER_IMAGE=apache/ozone-runner -ARG OZONE_RUNNER_VERSION=20251225-1-jdk21-slim +ARG OZONE_RUNNER_VERSION=20251226-1-jdk21-slim FROM ${OZONE_RUNNER_IMAGE}:${OZONE_RUNNER_VERSION} ARG OZONE_VERSION=2.0.0 @@ -37,11 +37,10 @@ RUN sudo rm -rf /opt/hadoop && \ README.md \ SECURITY.md \ share/ozone/byteman \ - smoketest \ - tests && \ - sudo rm -f \ share/ozone/lib/*-docs-*.jar \ - share/ozone/lib/ozone-filesystem-hadoop*.jar + share/ozone/lib/ozone-filesystem-hadoop*.jar \ + smoketest \ + tests WORKDIR /opt/hadoop From 1ecc39ff77e22a47b8a3d45b2aa53382f6967ab9 Mon Sep 17 00:00:00 2001 From: "Doroszlai, Attila" <6454655+adoroszlai@users.noreply.github.com> Date: Fri, 26 Dec 2025 08:56:11 +0100 Subject: [PATCH 7/7] Needs ncat --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a5aa71d..d5c7499 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ # limitations under the License. ARG OZONE_RUNNER_IMAGE=apache/ozone-runner -ARG OZONE_RUNNER_VERSION=20251226-1-jdk21-slim +ARG OZONE_RUNNER_VERSION=20251226-2-jdk21-slim FROM ${OZONE_RUNNER_IMAGE}:${OZONE_RUNNER_VERSION} ARG OZONE_VERSION=2.0.0