【docker】java镜像

傅阳炎
2023-12-01

https://github.com/docker-library/openjdk/blob/master/8/jdk/oraclelinux7/Dockerfile

FROM centos:7

USER root

WORKDIR /root

# https://github.com/AdoptOpenJDK/openjdk8-upstream-binaries/releases/download/jdk8u332-b09/OpenJDK8U-jdk_x64_linux_8u332b09.tar.gz
ADD openjdk.tgz .

# 环境变量配置
ENV JAVA_HOME /usr/java/openjdk-8
ENV PATH $JAVA_HOME/bin:$PATH
ENV LANG en_US.UTF-8
ENV DIR_NAME openjdk-8u332-b09

RUN mkdir -p $JAVA_HOME; mv $DIR_NAME/* $JAVA_HOME; \
# 类似于配置超链接,方便java命令执行
        for bin in "$JAVA_HOME/bin/"*; do \
                base="$(basename "$bin")"; \
                [ ! -e "/usr/bin/$base" ]; \
                alternatives --install "/usr/bin/$base" "$base" "$bin" 20000; \
        done; \
java -version; \
 类似资料: