这里记录下编写Dockerfile时java项目依赖的的基础镜像,基础镜像主要有如下几项配置:
1、依赖的基础环境,这里选择centos;
2、设置镜像的时区,这里选择 Asia/Shanghai;
3、安装需要的基础命令,如 wget、unzip,
4、配置jdk环境;
# Base image
FROM centos:latest
MAINTAINER bobo <xxx@qq.com>
# set timezone
ENV TIME_ZONE Asia/Shanghai
RUN ln -sf /usr/share/zoneinfo/${TIME_ZONE} /etc/localtime
#OS
RUN yum install -y wget && yum install -y unzip zip
#install jdk
RUN mkdir /var/tmp/jdk
# 这里oracle官方下载不可用了,本地引入jdk
#RUN wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" -P /var/tmp/jdk http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
COPY jdk-8u271-linux-x64.tar.gz /var/tmp/jdk/jdk-8u271-linux-x64.tar.gz
RUN tar xzf /var/tmp/jdk/jdk-8u271-linux-x64.tar.gz -C /var/tmp/jdk && rm -rf /var/tmp/jdk/jdk-8u271-linux-x64.tar.gz
#env
ENV JAVA_HOME /var/tmp/jdk/jdk1.8.0_271
ENV PATH $PATH:$JAVA_HOME/bin