1.下载JDK包或者从启动好的容器中将JDK拷贝出来
- jdk-8u221-linux-x64.tar.gz
2.创建Dockerfile
- 新建一个文件夹方便用来打包
mkdir jdk
cp jdk-8u221-linux-x64.tar.gz ./jdk
- 编写Dockerfile
# This is a JDK servic docker
FROM centos:centos7
MAINTAINER bigeyes
ADD jdk-8u221-linux-x64.tar.gz /usr/local
ENV JAVA_HOME /usr/local/jdk1.8.0_221
ENV JRE_HOME /usr/local/jdk1.8.0_221/jre
ENV PATH $JAVA_HOME/bin:$PATH
- 构建JDK镜像
docker build -t jdk:v1 .