前提文章:https://www.cnblogs.com/sanduzxcvbnm/p/15736328.html
从原有镜像中复制出一份web.xml,默认在这个目录下:/opt/apache-tomcat-8.5.3/conf/web.xml
修改该文件,增加如下内容:
<!--跨域设置-->
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
具体位置如下图:
然后自己构造一个Dockerfile文件,把修改过的web.xml文件添加进去
FROM davidcaste/alpine-tomcat:jre8tomcat8
MAINTAINER sandu <1103324414@qq.com>
COPY web.xml /opt/apache-tomcat-8.5.3/conf/web.xml
最后构造一个新镜像,直接引用就行了