美文网首页
docker容器中中文乱码

docker容器中中文乱码

作者: 逍遥_yjz | 来源:发表于2021-09-26 20:45 被阅读0次

报错:
docker UnicodeEncodeError: 'ascii' codec can't encode characters in position 70-72: o
以上错误问题,不单单指docker 内,还有单独centos,同样解决。
解决方法:

1. 制作镜像 - dockerfile 文件

在dockerfile增加

RUN yum install kde-l10n-Chinese -y && \
 yum install glibc-common -y && \
 localedef -c -f UTF-8 -i zh_CN zh_CN.utf8

ENV LC_ALL zh_CN.UTF-8

验证 --> 查看自己系统支持哪些语言包,可以调用指令:

locale -a

结果:


2. 制作镜像 - 更新镜像

yum install kde-l10n-Chinese -y 
yum install glibc-common -y 
localedef -c -f UTF-8 -i zh_CN zh_CN.utf8

配置环境变量

[root ~]# vim  ~/.bashrc
# .bashrc
 
# User specific aliases and functions
 
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
 
# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

在里面添加一句

export LC_ALL=zh_CN.UTF-8

就成功解决啦!

相关文章

网友评论

      本文标题:docker容器中中文乱码

      本文链接:https://www.haomeiwen.com/subject/ftrcnltx.html