1.最基礎的oracle-jdkhtml
FROM centos:7.2.1511 MAINTAINER hongdada "hongdaqi159505@gmail.com" #install required packages RUN yum -y update && \ yum -y install wget && \ yum -y install tar #set Oracle Java8 variables ENV JAVA_VERSION 8u151 ENV JAVA_BUILD 8u151-b12 ENV JAVA_DL_HASH e758a0de34e24606bca991d704f6dcbf ENV ORACLE_MIRROR_URL http://download.oracle.com RUN mkdir -p /usr/lib/jvm && \ echo "Download Oracle JDK ${JAVA_VERSION}..." && \ wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "${ORACLE_MIRROR_URL}/otn-pub/java/jdk/${JAVA_BUILD}/${JAVA_DL_HASH}/jdk-${JAVA_VERSION}-linux-x64.tar.gz" -O /tmp/jdk-${JAVA_VERSION}.tgz && \ tar xzf /tmp/jdk-${JAVA_VERSION}.tgz -C /usr/lib/jvm && \ rm /tmp/jdk-${JAVA_VERSION}.tgz RUN alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_151/bin/java 2 RUN alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.8.0_151/bin/jar 2 RUN alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_151/bin/javac 2 RUN alternatives --set jar /usr/lib/jvm/jdk1.8.0_151/bin/jar RUN alternatives --set javac /usr/lib/jvm/jdk1.8.0_151/bin/javac ENV JAVA_HOME /usr/lib/jvm/jdk1.8.0_151 ENV JRE_HOME /usr/lib/jvm/jdk1.8.0_151/jre ENV PATH $PATH:${JAVA_HOME}:${JRE_HOME}/bin
2.tomcat:java
FROM fore84/oracle-jdk:1.8 MAINTAINER Frank Ore <frank.ore@live.com> #TOMCAT_TARGZ_URLS #https://www-us.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz #https://www-eu.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz #https://www.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz #TOMCAT_MIRRORS_URLS #https://www-us.apache.org #https://www-eu.apache.org #https://www.apache.org ENV TOMCAT_MIRROR_URL https://www-us.apache.org ENV TOMCAT_MAJOR 8 ENV TOMCAT_VERSION 8.5.23 ENV CATALINA_HOME /opt/tomcat RUN echo "Installing Tomcat ${TOMCAT_VERSION}..." && \ wget -nv ${TOMCAT_MIRROR_URL}/dist/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz -O /tmp/tomcat.tgz && \ tar xzf /tmp/tomcat.tgz -C /opt && \ mv /opt/apache-tomcat-${TOMCAT_VERSION} ${CATALINA_HOME} && \ rm /tmp/tomcat.tgz ENV PATH $PATH:$CATALINA_HOME/bin EXPOSE 8080 # Launch Tomcat CMD ["/opt/tomcat/bin/catalina.sh", "run"]
3.springmvclinux
FROM fore84/oracle-jdk:1.8 MAINTAINER Frank Ore <frank.ore@live.com> #TOMCAT_TARGZ_URLS #https://www-us.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz #https://www-eu.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz #https://www.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz #TOMCAT_MIRRORS_URLS #https://www-us.apache.org #https://www-eu.apache.org #https://www.apache.org ENV TOMCAT_MIRROR_URL https://www-us.apache.org ENV TOMCAT_MAJOR 8 ENV TOMCAT_VERSION 8.5.23 ENV CATALINA_HOME /opt/tomcat RUN echo "Installing Tomcat ${TOMCAT_VERSION}..." && \ wget -nv ${TOMCAT_MIRROR_URL}/dist/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz -O /tmp/tomcat.tgz && \ tar xzf /tmp/tomcat.tgz -C /opt && \ mv /opt/apache-tomcat-${TOMCAT_VERSION} ${CATALINA_HOME} && \ rm /tmp/tomcat.tgz COPY SpringMVC.war /opt/tomcat/webapps ENV PATH $PATH:$CATALINA_HOME/bin EXPOSE 8080 # Launch Tomcat CMD ["/opt/tomcat/bin/catalina.sh", "run"]
4.springboot:git
# FROM指定使用哪一個鏡像做爲基準 FROM openjdk:8-jdk-alpine # VOLUME爲掛載路徑 -v VOLUME /tmp # ADD爲複製文件到鏡像中 ADD springboot-docker.jar app.jar # RUN爲初始化時運行的命令 touch更新app.jar RUN sh -c 'touch /app.jar' # ENV爲設置環境變量 ENV JAVA_OPTS="" # ENTRYPOINT爲啓動時運行的命令 ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
參考:github
https://hub.docker.com/r/fore84/oracle-jdk/~/dockerfile/web
https://github.com/frankore84/SpringMVC/tree/master/1.1spring
https://github.com/jessfraz/dockerfilesdocker