JDK下载网址:https://www.oracle.com/java/technologies/javase-downloads.html
基于centos7-JDK镜像制作
jdk8 dockerfile
#jdk8u191 image
FROM centos-base:7.7.1908
LABEL mail=timerovers@163.com
LABEL des=jdk1.8.0_191
ARG JAVA="jdk-8u191-linux-x64"
ADD $JAVA.tar.gz /usr/local/
# configuration of java ENV
ENV JAVA_HOME /usr/local/jdk1.8.0_191
ENV JRE_HOME $JAVA_HOME/jre
ENV CLASSPATH $JAVA_HOME/lib/:$JRE_HOME/lib/
ENV PATH $PATH:$JAVA_HOME/bin
基于alpine镜像制作
openjdk8 apk安装
cat build.sh
#!/bin/bash
docker build -t openjdk-base:1.8.242 .
cat Dockerfile
#java version 1.8.0_242
FROM alpine-base:3.11
LABEL mail=timerovers@163.com
ARG JAVA="jdk-8u191-linux-x64"
ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk \
PATH=$PATH:/usr/lib/jvm/java-1.8-openjdk/jre/bin \
run_foreground=true
RUN apk add --no-cache openjdk8 && rm -rf /var/cache/apk/*
[root@localhost jdk-8u191]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
openjdk-base 1.8.242 5d51376ed3b6 21 minutes ago 161MB
基于ubuntu18.04镜像制作
cat build.sh
#!/bin/bash
docker build -t jdk-base:1.8.191 .
cat Dockerfile
#jdk8u191 image
#java version 1.8.0_191
FROM ubuntu-base:18.04
LABEL mail=timerovers@163.com
ARG JAVA="jdk-8u191-linux-x64"
ADD $JAVA.tar.gz /usr/local/
# configuration of java ENV
ENV JAVA_HOME /usr/local/jdk1.8.0_191
ENV JRE_HOME $JAVA_HOME/jre
ENV CLASSPATH $JAVA_HOME/lib/:$JRE_HOME/lib/
ENV PATH $PATH:$JAVA_HOME/bin
[root@localhost jdk-8u191]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
jdk-base 1.8.191 ee0223a66ac2 2 minutes ago 460MB