[root@5434211632bc /]# history
1 yum install -y kde-l10n-Chinese
2 yum reinstall -y glibc-common
3 rpm -qa | grep glibc-common-2.17-222.el7.x86_64
4 yum groupinstall "fonts" -y
5 yum install -y system-config-language
6 localedef -c -f UTF-8 -i zh_CN zh_CN.utf8 # 定义字符集
7 localedef -c -f GBK -i zh_CN zh_CN.GBK
8 localedef -c -f GB2312 -i zh_CN zh_CN.GB2312 9 locale -a 10 cat /etc/locale.conf 11 echo 'LANG="zh_CN.UTF-8"' > /etc/locale.conf # 修改系统字符集 12 cat /etc/locale.conf 13 source /etc/locale.conf 14 echo 'export LC_ALL="zh_CN.utf8"' >> /etc/profile 15 source /etc/profile 16 locale 17 history
第15步骤时若报错误:
bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.utf8): No such file or directory bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.utf8): No such file or directory
解决办法:
可能是执行localedef -c -f UTF-8 -i zh_CN zh_CN.utf8步骤时,写成了localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8
如果还乱码,执行以下命令:
[root@650da1307bb1 fonts]# cd /usr/share/fonts/[root@650da1307bb1 fonts]# fc-cache -fv
#### 生成镜像 ##########
docker commit -m 'test' e265924baa80 centos:7-utf8
########### dockerfile ##############################################
FROM centos:7RUN
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
&& yum -y install kde-l10n-Chinese
&& yum -y reinstall glibc-common
&& localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8
&& echo 'LANG="zh_CN.UTF-8"' > /etc/locale.conf
&& source /etc/locale.conf
&& yum clean all
ENV LANG=zh_CN.UTF-8
LC_ALL=zh_CN.UTF-8