NGINX
1、nginx.conf里主要配置信息
location /xiaofei{
root html;
index index.html index.htm;
proxy_pass http://lnmp_tomcat:8080/xiaofei;
proxy_set_header Host $host;
proxy_set_header Remote_Addr $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
2、Dockerfile内容
FROM docker.io/centos
LABEL "auth"="Uncle.joker" \
"mail"="unclejoker520@163.com"
ENV TIME_ZOME Asia/Shanghai
RUN yum install -y gcc gcc-c++ make openssl-devel prce-devel
ADD nginx-1.14.2.tar.gz /opt/
RUN cd /opt/nginx-1.14.2 && \
./configure --prefix=/usr/local/nginx && \
make -j 4 && \
make install
RUN rm -rf /opt/nginx* && \
yum clean all && \
echo "${TIME_ZOME}" > /etc/timezone && \
ln -sf /usr/share/zoneinfo/${TIME_ZOME} /etc/localtime
COPY nginx.conf /usr/local/nginx/conf/
WORKDIR /usr/local/nginx/
EXPOSE 80
CMD ["./sbin/nginx","-g","daemon off;"]
3、Duild镜像
# cd /root/dockerfile/nginx && docker build -t mytomcat/nginx:1.5 .
4、启动镜像
# docker run -itd --name nginx1 --network lnmp -p 8888:80 mytomcat/nginx:1.5
TOMCAT
1、目录结构如下
[root@ecs-5704-0004 tomcat]# tree ./
./
├── apache-tomcat-7.0.92.tar.gz
├── catalina.sh
├── Dockerfile
├── jdk-7u80-linux-x64.tar.gz
└── server.xml
2、配置文件内容
(1)、server.xml
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxThreads="2000"
minSpareThreads="25"
acceptCount="2000"
disableUploadTimeout="true"
enableLookups="false"
useBodyEncodingForURI="true"
URIEncoding="UTF-8" />
<Connector port="8009"
protocol="AJP/1.3"
connectionTimeout="20000"
redirectPort="8443"
maxThreads="2000"
minSpareThreads="25"
acceptCount="2000"
disableUploadTimeout="true"
enableLookups="false"
URIEncoding="UTF-8" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="/xiaofei" docBase="/data/apps/fireway" crossContext="true" reloadable="false"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
(2)、catalina.sh配置内容如下
主要是在启动脚本的内容下增加了内存等信息的调优。
JAVA_OPTS="-server -Xms6G -Xmx6G -Xmn2248M -XX:PermSize=384M -XX:MaxPermSize=700M -Xss256K -XX:+DisableExplicitGC -XX:SurvivorRa
tio=4 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBef
oreCompaction=0 -XX:+CMSClassUnloadingEnabled -XX:LargePageSizeInBytes=128M -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccu
pancyOnly -XX:CMSInitiatingOccupancyFraction=80 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+PrintClassHistogram -XX:+PrintGCDetails -XX:+
PrintGCDateStamps -XX:+PrintHeapAtGC -verbose:gc -Xloggc:$CATALINA_BASE/logs/gc.log "
3、Dockerfile里的内容
FROM docker.io/centos
LABEL "auth"="Uncle.Joker" \
"mail"="unclejoker520@163.com"
ENV TIME_ZOME Asia/Shanghai
#--config JDK.1.7
ADD jdk-7u80-linux-x64.tar.gz /opt/
ENV JAVA_HOME /opt/jdk1.7.0_80
ENV PATH ${JAVA_HOME}/bin:${PATH}
#--config TOMCAT 7
ADD apache-tomcat-7.0.92.tar.gz /usr/local/
RUN mv /usr/local/apache-tomcat-7.0.92 /usr/local/tomcat
COPY server.xml /usr/local/tomcat/conf/
COPY catalina.sh /usr/local/tomcat/bin/
RUN chmod +x /usr/local/tomcat/bin/catalina.sh
WORKDIR /usr/local/tomcat
EXPOSE 8080
CMD ["./bin/catalina.sh","run"]
4、Build镜像
# /root/dockerfile/tomcat && docker build -t mytomcat:7.0.92_latest .
5、启动镜像
# docker run -itd --name lnmp_tomcat --network lnmp -v /root/dockerfile/app/tomcat/:/data/apps/fireway mytomcat:7.0.92_latest
转载于:https://blog.51cto.com/7834466/2341398