1、Dockerfile
ARG java_image_tag=17-jre
FROM eclipse-temurin:${java_image_tag}
COPY sources.list /etc/apt/sources.list
RUN set -ex && \
apt-get update && \
apt-get install -y \
bash \
tini \
libc6 \
libpam-modules vim tar git wget curl rsync bzip2 iptables tcpdump less telnet net-tools lsof rpm \
krb5-user gcc automake make telnet net-tools \
libnss3 net-tools \
procps \
lvm2 tcpdump netcat-openbsd && \
ln -s /lib /lib64 && \
rm -rf /var/cache/apt/* /var/lib/apt/lists/*RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo 'Asia/Shanghai' > /etc/timezoneWORKDIR /opt
RUN wget https://download.oracle.com/java/17/archive/jdk-17.0.12_linux-aarch64_bin.tar.gz
# 解压 JDK 到 /usr/java/ 目录
RUN mkdir -p /usr/java && \
tar -xzvf jdk-17.0.12_linux-aarch64_bin.tar.gz -C /usr/javaRUN chmod -R 777 /usr/java/jdk-17.0.12
RUN wget -O /opt/apache-zookeeper-3.8.4-bin.tar.gz https://dlcdn.apache.org/zookeeper/zookeeper-3.8.4/apache-zookeeper-3.8.4-bin.tar.gz && \
tar -zxvf /opt/apache-zookeeper-3.8.4-bin.tar.gz -C /opt && \
cp -r /opt/apache-zookeeper-3.8.4-bin /opt/zookeeper && \
chmod -R 777 /opt/zookeeper
ADD start-zookeeper /opt/zookeeper/bin
ADD zookeeper-metrics /opt/zookeeper/bin
ADD zookeeper-ready /opt/zookeeper/binRUN chmod -R 777 /opt/zookeeper/bin
# 可选:列出 zookeeper 目录以验证解压内容(可以根据需要删除)
RUN ls -l /opt/zookeeperENV ZOOKEEPER_HOME /opt/zookeeper
ENV JAVA_HOME /usr/java/jdk-17.0.12
ENV CLASSPATH .:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV PATH $PATH:$JAVA_HOME/bin:$ZOOKEEPER_HOME/binMAINTAINER liebe
ENV LANG=C.UTF-8
EXPOSE 22 80 443 9090
2、镜像构建
docker buildx build --load --platform linux/arm64 --tag zookeeper:3.8.4 .
还有其他sources.list、start-zookeeper、zookeeper-metrics、zookeeper-ready
3、 sources.list
deb https://mirrors.aliyun.com/ubuntu-ports/ noble main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ noble main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu-ports/ noble-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ noble-security main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu-ports/ noble-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ noble-updates main restricted universe multiverse# deb https://mirrors.aliyun.com/ubuntu-ports/ noble-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu-ports/ noble-proposed main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu-ports/ noble-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ noble-backports main restricted universe multiverse
4、start-zookeeper
#!/usr/bin/env bash
# Copyright 2017 The Kubernetes Authors.
#
# Licensed 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.
#
#
#Usage: start-zookeeper [OPTIONS]
# Starts a ZooKeeper server based on the supplied options.
# --servers The number of servers in the ensemble. The default
# value is 1.# --data_dir The directory where the ZooKeeper process will store its
# snapshots. The default is /opt/zookeeper/data.# --data_log_dir The directory where the ZooKeeper process will store its
# write ahead log. The default is
# /opt/zookeeper/data/log.# --conf_dir The directoyr where the ZooKeeper process will store its
# configuration. The default is /opt/zookeeper/conf.# --client_port Th