TOMCAT的docker镜像封装支持中文

Dockerfile如下,fonts是windows下的字体文件

FROM tomcat:8.5.54-jdk8
COPY ./fonts /usr/share/fonts/Fonts
COPY ./sources.list /etc/apt/sources.list
RUN apt update && apt install locales-all fontconfig ttf-dejavu  ttf-mscorefonts-installer -y  && rm -rf /var/cache/apk/* && chmod 777 -R /usr/share/fonts/Fonts && cd /usr/share/fonts && mkfontscale && mkfontdir && fc-cache -fv
ENV LANG zh_CN.utf8
#ENV LANG C.UTF-8
COPY --from=hengyunabc/arthas:latest /opt/arthas /opt/arthas

sources.list如下

deb http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb http://mirrors.aliyun.com/debian-security buster/updates main
deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib

deb-src http://mirrors.aliyun.com/debian-security buster/updates main
deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib

server.xml修改

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" URIEncoding="UTF-8"/> ## 增加UTF-8部分

catalina.sh修改

JAVA_OPTS="$JAVA_OPTS -Xms16384m -Xmx16384m -Djava.protocol.handler.pkgs=org.apache.catalina.webresources  -Dfile.encoding=UTF8 -Djava.awt.headless=true"  

## headless=true,解决验证码不显示
## -Dfile.encoding=UTF8,解决字符集问题
## -Duser.timezone=GMT+08,解决时区问题

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注