docker部署Tomcat并配置manageApp
1、docker部署Tomcat
docker pull tomcat:latest # 分析:需要挂载的文件夹为:conf logs webapps # copy 容器内文件夹 (直接创建也可) [root@peiyanbing ~]# docker cp mytomcat:/usr/local/tomcat/conf /home/tomcat_design/ [root@peiyanbing ~]# docker cp mytomcat:/usr/local/tomcat/logs /home/tomcat_design/ [root@peiyanbing ~]# docker cp mytomcat:/usr/local/tomcat/webapps /home/tomcat_design/
# 以下是本人挂载的tomcat sudo docker run -d -p 8080:8080 --privileged=true -v /home/tomcat_design/webapps:/usr/local/tomcat/webapps -v /home/tomcat_design/conf:/usr/local/tomcat/conf -v /home/tomcat_design/logs:/usr/local/tomcat/logs --restart=always tomcat
|
2、Tomcat 8.5 无法进入管理页面 manager app
报错截图:
解决需要3步:
1. 添加 Context
$CATALINA_HOME/conf/Catalina/localhost/下创建 manager.xml , 填入如下内容:
<Context privileged="true" antiResourceLocking="false" docBase="${catalina.home}/webapps/manager"> <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" /> </Context>
|
\2. 添加用户:
$tomcathome/conf/tomcat-users.xml 中的
标签内添加如下代码:
<role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <role rolename="admin-gui"/> <role rolename="admin-script"/> <user username="tomcatAdmin" password="tomcatAdmin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/> <user username="deploy" password="deploy" roles="manager-script"/>
|
- 注释访问限制:
$CATALINA_HOME/webapps/manager/META-INF/context.xml.
注释掉下面的内容:
4、有时候会因为上传war过大报错,是因为web.xml默认大小只有50M
修改manager的web.xml
$CATALINA_HOME\webapps\manager\WEB-INF\web.xml
把大小限制改大
<multipart-config> <max-file-size>52428800</max-file-size> <max-request-size>52428800</max-request-size> <file-size-threshold>0</file-size-threshold> </multipart-config>
<multipart-config> <max-file-size>524288000</max-file-size> <max-request-size>524288000</max-request-size> <file-size-threshold>0</file-size-threshold> </multipart-config>
|
5、重启Tomcat即可。