1.容器中安装和设置
1.1.进入容器查看已有语言包
默认情况下:
1.2 安装中文语言环境
如果没有zh_CN.utf8就安装。
方式1:
- #直接安装中文语言包
- apt-get install -y language-pack-zh-hans
复制代码 方式2:
- #安装中文语言环境
- apt-get install -y locales
- #生成中文环境
- echo "zh_CN.UTF-8 UTF-8" >> /etc/locale.gen
- locale-gen
复制代码 1.3 写入 bash.bashrc 文件
- echo -e "\n# chinese zh_CN.UTF-8" >> /etc/bash.bashrc
- echo -e "export LANG="zh_CN.UTF-8"" >> /etc/bash.bashrc
- echo -e "export LANGUAGE="zh_CN.UTF-8"" >> /etc/bash.bashrc
- echo -e "export LC_ALL="zh_CN.UTF-8"" >> /etc/bash.bashrc
复制代码 1.4 写入 profile 文件
- echo -e "\n# chinese zh_CN.UTF-8" >> /etc/profile
- echo -e "export LANG="zh_CN.UTF-8"" >> /profile
- echo -e "export LANGUAGE="zh_CN.UTF-8"" >> /etc/profile
- echo -e "export LC_ALL="zh_CN.UTF-8"" >> /etc/profile
复制代码 1.5 重启容器
2. dockerfile中安装和设置
- # 容器来源
- FROM
- # 换国内镜像,DEB822 格式
- RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources
- # 更新系统
- RUN apt -y update && apt -y upgrade
- # 安装中文环境
- RUN apt install -y locales && \
- echo 'zh_CN.UTF-8 UTF-8' >> /etc/locale.gen && \
- locale-gen
- #或者使用这种方式安装中文环境
- #run apt-get install -y language-pack-zh-hans
- # 设置中文
- RUN echo '\n# chinese zh_CN.UTF-8\n\
- export LANG="zh_CN.UTF-8"\n\
- export LANGUAGE="zh_CN.UTF-8"\n\
- export LC_ALL="zh_CN.UTF-8"\n' >> /etc/bash.bashrc
- RUN echo '\n# chinese zh_CN.UTF-8\n\
- export LANG="zh_CN.UTF-8"\n\
- export LANGUAGE="zh_CN.UTF-8"\n\
- export LC_ALL="zh_CN.UTF-8"\n' >> /etc/profile
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |