下载jdk-17
# wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz
Dockerfile
FROM ubuntu:22.04
ENV JAVA_HOME=/usr/local/jdk-17.0.5
ENV JRE_HOME=$JAVA_HOME/jre
ENV PATH=${JAVA_HOME}/bin:$PATH
ADD jdk-17_linux-x64_bin.tar.gz /usr/local/
RUN javac --version \
&& java --version
build-jdk-image.sh
#!/bin/bash
docker build -t uhub.service.ucloud.cn/wgs-test/jdk:17.0.5 .
构建jdk镜像
# ./build-jdk-image.sh
Sending build context to Docker daemon 181.6MB
Step 1/6 : FROM ubuntu:22.04
---> 6b7dfa7e8fdb
Step 2/6 : ENV JAVA_HOME=/usr/local/jdk-17.0.5
---> Using cache
---> 12980d32df01
Step 3/6 : ENV JRE_HOME=$JAVA_HOME/jre
---> Using cache
---> 2d4cfb85dab9
Step 4/6 : ENV PATH=${JAVA_HOME}/bin:$PATH
---> Using cache
---> 8cecf6d54391
Step 5/6 : ADD jdk-17_linux-x64_bin.tar.gz /usr/local/
---> f4bf062e7d2d
Step 6/6 : RUN javac --version && java --version
---> Running in a64bb9178cc7
javac 17.0.5
java 17.0.5 2022-10-18 LTS
Java(TM) SE Runtime Environment (build 17.0.5+9-LTS-191)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.5+9-LTS-191, mixed mode, sharing)
Removing intermediate container a64bb9178cc7
---> 142801e4f730
Successfully built 142801e4f730
Successfully tagged uhub.service.ucloud.cn/wgs-test/jdk:17.0.5
验证jdk镜像
# docker run --rm uhub.service.ucloud.cn/wgs-test/jdk:17.0.5 java --version
java 17.0.5 2022-10-18 LTS
Java(TM) SE Runtime Environment (build 17.0.5+9-LTS-191)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.5+9-LTS-191, mixed mode, sharing)