创建JDK镜像
vi dockerfile
FROM centos:7
ADD jdk-8u211-linux-x64.tar.gz /usr/local/
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
ENV JAVA_HOME /usr/local/jdk1.8.0_211
ENV CLASSPATH .:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
ENV PATH $PATH:$JAVA_HOME/bin:$JRE_HOME/bin
将jdk-8u211-linux-x64.tar.gz 和dockerfile 放至同一目录下
docker build -t jdk:v1.8.211 -t .
创建基于JDK的应用镜像
FROM jdk:v1.8.211
ADD springboot.jar springboot.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","springboot.jar"]
EXPOSE 8080
将springboot.jar 和dockerfile 放至同一目录下
docker build -t springboot .