针对Centos Dockerfile的写法,启动Java Jar应用
可以这样:
FROM centos:7
#
# UTF-8 by default
#
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
#
# Pull Zulu OpenJDK binaries from official repository:
#
ARG ZULU_REPO_VER=1.0.0-1
RUN rpm --import http://repos.azulsystems.com/RPM-GPG-KEY-azulsystems && \
curl -sLO https://cdn.azul.com/zulu/bin/zulu-repo-${ZULU_REPO_VER}.noarch.rpm && \
rpm -ivh zulu-repo-${ZULU_REPO_VER}.noarch.rpm && \
yum -q -y update && \
yum -q -y upgrade && \
yum -q -y install yum-plugin-versionlock tzdata && \
yum versionlock zulu17-*-17.0.5-* && \
yum -q -y install zulu17-jdk && \
yum clean all && \
rm -rf /var/cache/yum zulu-repo_${ZULU_REPO_VER}.noarch.rpm
ENV JAVA_HOME=/usr/lib/jvm/zulu17
#复制你的jar包到镜像中
COPY demo.jar /usr/local/demo.jar
#指定容器启动程序及参数
ENTRYPOINT java -jar -Xmn128m -Xms256m -Xmx256m /usr/local/demo.jar
缝合了以下内容:
zuluJDK download page: https://www.azul.com/downloads/?package=jdk 在这个页面可以找到centos 安装JDK的docker版本
打开的链接是这个:https://github.com/zulu-openjdk/zulu-openjdk/blob/master/centos/17-latest/Dockerfile 然后缝合一下菜鸟教程的Dockerfile写法得到以上内容。