If you use docker search centos in Docker Use docker pull docker.io/centos to download the base image This image does not support Chinese. You can use docker attach container ID to enter the container and use "locale" to view it. You can use "locale -a" to check the system language package, and you will find that there is no Chinese package Solution:1. yum install kde-l10n-Chinese -y install language pack (for centos 7) 2. yum reinstall glibc-common -y to update the gitbc package (because the image has castrated some functions of the package, it needs to be updated) 3. localedef -c -f UTF-8 -i zh_CN zh_CN.utf8 (set system language pack) 4. ENV LC_ALL zh_CN.UTF-8 is set by setting environment variables (you can directly modify the /etc/locale.conf file, but you need to reboot) 5. If you use Dockerfile, you can refer to the following # Version information FROM docker.io/centos:latest MAINTAINER mapengfei "[email protected]" #Set system encoding RUN yum install kde-l10n-Chinese -y RUN yum install glibc-common -y RUN localedef -c -f UTF-8 -i zh_CN zh_CN.utf8 #RUN export LANG=zh_CN.UTF-8 #RUN echo "export LANG=zh_CN.UTF-8" >> /etc/locale.conf #ENV LANG zh_CN.UTF-8 ENV LC_ALL zh_CN.UTF-8 Supplement: Change the character encoding of the Docker container to -zh_CN.UTF-8 Chinese character set Version History First edition on April 26, 2019 Problem DescriptionThe company's Java project uses openoffice and pdf2html to convert the file format. Word, ppt, and pdf files are all converted without problems, but excel shows garbled characters after conversion BackgroundThe project runs in a Docker container, Docker version: Docker version 18.06.1-ce, build e68fc7a Container system kernel version: 3.10.0-514.el7.x86_64 Container system version: Cent0S7 CauseAfter communicating with the architecture, we learned that word, pdf, and ppt files are converted through openoffice and pdf2html, but excel files are not handled in this way. Instead, they are implemented using open source java code on the Internet. After reading the code, the architecture found that this code reads the language configuration of the host system when converting Excel files, so it is determined that the cause of the problem is the system character encoding setting. WorkaroundChecking the system character encoding is fine (note the first three lines), it seems that the character set is set correctly. Check the first three lines for problems. It is said online that this is caused by not installing the Chinese character set. [root@4273aa460888 opt]# locale locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory LANG=zh_CN.UTF-8 LC_CTYPE="zh_CN.UTF-8" LC_NUMERIC="zh_CN.UTF-8" LC_TIME="zh_CN.UTF-8" LC_COLLATE="zh_CN.UTF-8" LC_MONETARY="zh_CN.UTF-8" LC_MESSAGES="zh_CN.UTF-8" LC_PAPER="zh_CN.UTF-8" LC_NAME="zh_CN.UTF-8" LC_ADDRESS="zh_CN.UTF-8" LC_TELEPHONE="zh_CN.UTF-8" LC_MEASUREMENT="zh_CN.UTF-8" LC_IDENTIFICATION="zh_CN.UTF-8" LC_ALL= Let's see which character sets are installed on this machine. Damn, there is no Chinese character set installed... (If it is not installed, it will be useless even if you set it up) [root@4273aa460888 opt]# locale -a locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_COLLATE to default locale: No such file or directory C POSIX en_US.utf8 Let's take a look at the contents of /etc/locale.conf. Damn, it's still the English character set... [root@4273aa460888 opt]# cat /etc/locale.conf LANG="en_US.UTF-8" OK, let's install the Chinese character set next Delete the language configuration in the yum.conf file sed -i '13'd /etc/yum.conf Install fonts and glibc yum install -y kde-l10n-Chinese glibc-common Let's take a look again. Finally, we have [root@35b0e9b16498 opt]# locale -a|grep zh zh_CN zh_CN.gb18030 zh_CN.gb2312 zh_CN.gbk zh_CN.utf8 zh_HK zh_HK.big5hkscs zh_HK.utf8 zh_SG zh_SG.gb2312 zh_SG.gbk zh_SG.utf8 zh_TW zh_TW.big5 zh_TW.euctw zh_TW.utf8 Let's modify the /etc/locale.conf file again echo -e 'export LANG="zh_CN.UTF-8"\nexport LC_ALL="zh_CN.UTF-8"' > /etc/locale.conf source /etc/locale.conf Let's take a look at the character encoding again. OK, there are no errors and everything is normal. [root@35b0e9b16498 opt]# locale LANG=zh_CN.UTF-8 LC_CTYPE="zh_CN.UTF-8" LC_NUMERIC="zh_CN.UTF-8" LC_TIME="zh_CN.UTF-8" LC_COLLATE="zh_CN.UTF-8" LC_MONETARY="zh_CN.UTF-8" LC_MESSAGES="zh_CN.UTF-8" LC_PAPER="zh_CN.UTF-8" LC_NAME="zh_CN.UTF-8" LC_ADDRESS="zh_CN.UTF-8" LC_TELEPHONE="zh_CN.UTF-8" LC_MEASUREMENT="zh_CN.UTF-8" LC_IDENTIFICATION="zh_CN.UTF-8" LC_ALL=zh_CN.UTF-8 The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me. You may also be interested in:
|
<<: IE8 compatibility notes I encountered
>>: Example of how rem is adapted for mobile devices
This article records the installation and configu...
Using Navicat directly to connect via IP will rep...
This article example shares the specific code of ...
Table of contents 1. v-text (v-instruction name =...
This article shares the specific code of JavaScri...
This article shares the installation and configur...
How to set up a MySQL short link 1. Check the mys...
About the tree display of Vue, the project is use...
Table of contents Preface Axios installation and ...
This method uses the drop-shadow filter in CSS3 t...
This should be something that many people have do...
There has been a lot of discussion about H1 recent...
Since my development environment is to install Ce...
Table of contents Preface Computed properties Int...
Recently, I need to frequently use iframe to draw ...