JDK
FROM centos:centos7
MAINTAINER Denlin [email protected]
# 时间更新
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo 'Asia/Shanghai' >/etc/timezone
# 仓库源配置
RUN rm -rf /etc/yum.repos.d/*.repo \
&& curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo \
&& curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo \
&& yum clean all \
&& yum makecache \
# 用户创建
&& groupadd -g 1000 www \
&& useradd -u 1000 -g 1000 www -M -s /sbin/nologin
# profile更新 jdk安装 变量申明
ADD profile /etc/profile
ADD jdk-8u181-linux-x64.tar.gz /opt
RUN ln -s /opt/jdk1.8.0_181 /opt/jdk
ENV JAVA_HOME /opt/jdk
ENV JRE_HOME $JAVA_HOME/jre
ENV CLASSPATH $JAVA_HOME/lib:$JRE_HOME/lib
ENV PATH $PATH:$JAVA_HOME/bin
CMD ["bash"]
构建JDK镜像
docker build -t jdk1.8 .
测试
# 测试java版本
docker run jdk1.8 bash -c 'java -version'
# halo博客jar部署
# 准备好halo.jar
docker run -d -p 8090:8090 -v /opt/docker/dockerfile/jdk/halo:/halo jdk1.8 java -jar /halo/halo-1.4.1.jar
# 浏览器访问宿主机ip:8090
标签:jdk,repo,etc,构建,&&,HOME,Dockerfile,halo
From: https://www.cnblogs.com/ctynlnlnl/p/18283213