# 建立一个新的镜像文件,配置模板:新建立的镜像是以centos为基础模板
# 因为jdk必须运行在操作系统之上
FROM centos:7.9.2009# 作者名
MAINTAINER yuanhang# 创建一个新目录来存储jdk文件
RUN mkdir /usr/local/java#将jdk压缩文件复制到镜像中,它将自动解压缩tar文件
ADD jdk-11_linux-x64_bin.tar.gz /usr/local/java/# 设置时区
RUN mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
ADD ./CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
RUN yum clean all
RUN yum makecacheRUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN yum install dejavu-sans-fonts fontconfig -y
# 设置环境变量
ENV JAVA_HOME /usr/local/java/jdk-11
ENV PATH $JAVA_HOME/bin:$PATH# VOLUME 指定了临时文件目录为/tmp
# 其效果是在主机 /var/lib/docker 目录下创建了一个临时文件,并链接到容器的/tmp
VOLUME /tmp
docker 镜像
https://docker.m.daocloud.io
centos7.9 yum源 CentOS-Base.repo
# CentOS-Base.repo## The mirror system uses the connecting IP address of the client and the# update status of each mirror to pick mirrors that are updated to and# geographically close to the client. You should use this for CentOS updates# unless you are manually picking other mirrors.## If the mirrorlist= does not work for you, as a fall back you can try the# remarked out baseurl= line instead.##[base]name=CentOS-$releasever - Base - mirrors.aliyun.comfailovermethod=prioritybaseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/os/$basearch/gpgcheck=1gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7#released updates[updates]name=CentOS-$releasever - Updates - mirrors.aliyun.comfailovermethod=prioritybaseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/updates/$basearch/gpgcheck=1gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7#additional packages that may be useful[extras]name=CentOS-$releasever - Extras - mirrors.aliyun.comfailovermethod=prioritybaseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/extras/$basearch/gpgcheck=1gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7#additional packages that extend functionality of existing packages[centosplus]name=CentOS-$releasever - Plus - mirrors.aliyun.comfailovermethod=prioritybaseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/centosplus/$basearch/gpgcheck=1enabled=0gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7#contrib - packages by Centos Users[contrib]name=CentOS-$releasever - Contrib - mirrors.aliyun.comfailovermethod=prioritybaseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/contrib/$basearch/gpgcheck=1enabled=0gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7