Docker中文乱码解决

中文 dockerfile 支持

1
2
3
4
5
6
7
FROM centos
MAINTAINER fengwan.blog.51cto.com
RUN rm -rf /etc/localtime && ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #修改时区
RUN yum -y install kde-l10n-Chinese && yum -y reinstall glibc-common #安装中文支持
RUN localedef -c -f UTF-8 -i zh_CN zh_CN.utf8 #配置显示中文
ENV LC_ALL zh_CN.utf8 #设置环境变量
RUN yum -y install python-setuptools && easy_install pip && pip install superviso

alphi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# using alpine-glibc instead of alpine  is mainly because JDK relies on glibc
FROM docker.io/jeanblanchard/alpine-glibc
# author
MAINTAINER ygsama@qq.com
# A streamlined jre
ADD jre8.tar.gz /usr/java/jdk/
ADD msyhbd.ttc  /opt/
ADD msyhl.ttc   /opt/
ADD msyh.ttc    /opt/
ADD simhei.ttf  /opt/
ADD simkai.ttf  /opt/
ADD simsun.ttc  /opt/
# set env
ENV JAVA_HOME /usr/java/jdk
ENV PATH ${PATH}:${JAVA_HOME}/bin
ENV CLASSPATH ${CLASSPATH}:${JAVA_HOME}/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
# run container with base path:/opt
WORKDIR /opt
# install font
RUN apk add font-adobe-100dpi \
    && chmod 777 *.ttc \
    && chmod 777 *.ttf \
    && mkdir /usr/share/fonts/win \
    && mv msyhbd.ttc /usr/share/fonts/win/  \
    && mv msyhl.ttc  /usr/share/fonts/win/  \
    && mv msyh.ttc   /usr/share/fonts/win/  \
    && mv simhei.ttf /usr/share/fonts/win/  \
    && mv simkai.ttf /usr/share/fonts/win/  \
    && mv simsun.ttc /usr/share/fonts/win/  \
    && fc-cache -f \
    && fc-list

参考文档:

https://blog.csdn.net/zimou5581/article/details/101368129

https://juejin.cn/post/6844903952824156167

Licensed under CC BY-NC-SA 4.0
最后更新于 Jan 06, 2025 05:52 UTC
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计
Caret Up