docker发布java项目选择基础镜像包
1:openjdk:8-jdk-alpine3.9
大小:105M
配置:
#基础镜像使用java
FROM openjdk:8-jdk-alpine3.9
ENV LANG en_US.UTF-8
# 修改时区和安装字体
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
&& apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone && apk del tzdata \
&& apk add --update ttf-dejavu fontconfig && rm -rf /var/cache/apk/*
ARG JAR_FILE=./target/*.jar
COPY ${JAR_FILE} app.jar
EXPOSE 8081
ENTRYPOINT ["java","-jar","/app.jar"]
2:openjdk:8
大小:526M
配置:
#基础镜像使用java
FROM openjdk:8
ARG JAR_FILE=./target/*.jar
COPY ${JAR_FILE} app.jar
EXPOSE 13000
ENTRYPOINT ["java","-jar","/app.jar"]
3:openjdk:8u312-jre-slim-buster
大小:187M
配置:
#基础镜像使用java
FROM openjdk:8u312-jre-slim-buster
ENV LANG en_US.UTF-8
# 修改时区和安装字体
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
&& apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone && apk del tzdata \
&& apk add --update ttf-dejavu fontconfig && rm -rf /var/cache/apk/*
ARG JAR_FILE=./target/*.jar
COPY ${JAR_FILE} app.jar
EXPOSE 8081
ENTRYPOINT ["java","-jar","/app.jar"]