前期准备
传送门: https://www.java.com/en/download/manual.jsp
此处以1.8.0_351版本为例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| tar -zxvf jre-8u351-linux-x64.tar.gz
cd jre1.8.0_351
rm -rf COPYRIGHT \ LICENSE \ README \ release \ THIRDPARTYLICENSEREADME-JAVAFX.txt \ THIRDPARTYLICENSEREADME.txt \ Welcome.html lib/plugin.jar \ lib/ext/jfxrt.jar \ bin/javaws \ lib/javaws.jar \ lib/desktop \ plugin \ lib/deploy* \ lib/*javafx* \ lib/*jfx* \ lib/amd64/libdecora_sse.so \ lib/amd64/libprism_*.so \ lib/amd64/libfxplugins.so \ lib/amd64/libglass.so \ lib/amd64/libgstreamer-lite.so \ lib/amd64/libjavafx*.so \ lib/amd64/libjfx*.so
|
构建Docker镜像
Dockerfile
如下所示
1 2 3 4 5 6
| FROM centos:7 MAINTAINER ruochen ADD jre1.8.0_351 /usr/java/ ENV JAVA_HOME /usr/java/jre1.8.0_351 ENV PATH ${PATH}:${JAVA_HOME}/bin WORKDIR /home/
|
构建镜像
1
| DOCKER_BUILDKIT=1 docker build --progress=plain --platform=linux/amd64 -t ruochen/centos7:jre1.8.351 -f Dockerfile .
|
验证镜像
1
| docker run -it --entrypoint /bin/bash ruochen/centos7:jre1.8.351 bash
|
执行java
命令进行验证即可.