One, make the smallest jdk mirror
1、下载jre8:https://www.java.com/en/download/manual.jsp
2. Delete redundant files
a. Unzip the compressed package
$ tar -xvcf jre-8u181-linux-x64.tar.gz
b, delete redundant files
$ cd jre1.8.0_181/
$ rm -rf COPYRIGHT LICENSE README release THIRDPARTYLICENSEREADME-JAVAFX.txt THIRDPARTYLICENSEREADME.txt Welcome.html
$ rm -rf 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
c, repack
$ tar zcvf jre8.tar.gz *
3. Write Dockerfile (place jre8.tar.gz and Dockerfile in the same directory)
FROM docker.io/jeanblanchard/alpine-glibc
MAINTAINER micheal
ADD jre8.tar.gz /usr/java/jdk/
ENV JAVA_HOME /usr/java/jdk
ENV PATH ${PATH}:${JAVA_HOME}/bin
WORKDIR /opt
4. Build a mirror
$docker build -t jdk1.8-mini:v1 .
Note: The image built according to this method will have the problem of Chinese garbled characters. Refer to the solution: https://blog.csdn.net/zhuchuanwan/article/details/102957332 ; if you don’t pay attention to the problem of Chinese garbled characters, you can use it directly.
Second, build the springboot project image
1. Type the springboot project into a jar package
2. Write Dockerfile (place jre8.tar.gz and search-demo.jar in a unified directory)
FROM docker.io/jeanblanchard/alpine-glibc
MAINTAINER simon
ADD jre8.tar.gz /usr/java/jdk/
ENV JAVA_HOME /usr/java/jdk
ENV PATH ${PATH}:${JAVA_HOME}/bin
WORKDIR /opt
ADD search-demo.jar .
ENTRYPOINT ["java","-jar","./search-demo.jar"]
3. Build a mirror
$docker build -t demo:v2 .
Three, start the mirror
1. Start
docker run -d -p 8082:8080 demo:v2 sh
2. View the startup result
$docker ps -a
Successful startup: