docker使用centos7系统构建tomcat镜像
FROM shansongxian/centos-oraclejdk8:latest #此镜像使用centos7系统,精简jdk,只运行java程序,无法编译/构建 MAINTAINER huqiang:2018/10/12 ENV VERSION=8.5.34 ENV CATALINA_HOME /usr/local/tomcat ENV PATH $CATALINA_HOME/bin:$PATH ENV CATALINA_OPTS=" \ -Xms1g \ -Xmx1g \ -Xss512k \ -Xmn500m \ -XX:MetaspaceSize=128m \ -XX:MaxMetaspaceSize=512m \ -Xloggc:$CATALINA_HOME/logs/gc.log \ -XX:+PrintGCDetails \ -XX:+PrintGCDateStamps \ -XX:+PrintPromotionFailure \ -XX:-UseBiasedLocking \ -XX:AutoBoxCacheMax=20000 \ -XX:+AlwaysPreTouch \ -Djava.security.egd=file:/dev/./urandom \ -XX:+ExplicitGCInvokesConcurrent \ -XX:+ParallelRefProcEnabled \ -XX:+UseConcMarkSweepGC \ -XX:CMSInitiatingOccupancyFraction=75 \ -XX:+UseCMSInitiatingOccupancyOnly \ -XX:-CMSClassUnloadingEnabled \ -XX:+CMSScavengeBeforeRemark \ -XX:+HeapDumpOnOutOfMemoryError \ -XX:HeapDumpPath=$CATALINA_HOME/logs \ -XX:OnOutOfMemoryError=$CATALINA_HOME/bin/stop.sh \ -XX:ErrorFile=$CATALINA_HOME/logs/hs_err_%p.log \ -XX:+PrintCommandLineFlags \ -XX:+PrintFlagsFinal \ -XX:-OmitStackTraceInFastThrow \ -Duser.timezone=Asia/Shanghai \ -Djavax.servlet.request.encoding=UTF-8 \ -Djavax.servlet.response.encoding=UTF-8 \ -Dfile.encoding=UTF-8 \ -Duser.country=CN \ -Duser.language=zh \ -Djava.awt.headless=true \ -Dcom.sun.management.jmxremote.port=1099 \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.authenticate=false \ -Djava.rmi.server.hostname=0.0.0.0" RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime RUN wget http://mirrors.shu.edu.cn/apache/tomcat/tomcat-8/v${VERSION}/bin/apache-tomcat-${VERSION}.tar.gz \ && tar zxf apache-tomcat-${VERSION}.tar.gz \ && mv apache-tomcat-${VERSION} $CATALINA_HOME \ && rm -rf apache-tomcat-${VERSION}.tar.gz $CATALINA_HOME/webapps/* $CATALINA_HOME/bin/*.bat \ && mkdir $CATALINA_HOME/webapps/ROOT \ # 处理Tomcat启动慢问题(随机数产生器初始化过慢) && sed -i "s#securerandom.source=file:/dev/random#securerandom.source=file:/dev/./urandom#g" $JAVA_HOME/jre/lib/security/java.security WORKDIR $CATALINA_HOME EXPOSE 8080 CMD ["catalina.sh", "run"]
说明:
-Djava.rmi.server.hostname=www.tomcat.com" 使用主机名,在客户机添加hosts解析访问