docker 容器终端 无法输入中文
参考
https://cloud.tencent.com/developer/article/1500399
#查看字符集
点击查看代码
``` root@6900b666a425:/# locale LANG= LANGUAGE= LC_CTYPE="POSIX" LC_NUMERIC="POSIX" LC_TIME="POSIX" LC_COLLATE="POSIX" LC_MONETARY="POSIX" LC_MESSAGES="POSIX" LC_PAPER="POSIX" LC_NAME="POSIX" LC_ADDRESS="POSIX" LC_TELEPHONE="POSIX" LC_MEASUREMENT="POSIX" LC_IDENTIFICATION="POSIX" LC_ALL= #查看支持的字符集 root@6900b666a425:/# locale -a C C.UTF-8 POSIX #postx字符集不支持中文需要切换UTF-8 ```解决
docker exec -it 容器id env LANG=C.UTF-8 /bin/bash
点击查看代码
[root@VM-20-6-centos conf]# docker exec -it 6900b666a425 env LANG=C.UTF-8 /bin/bash
#再次查看字符集
root@6900b666a425:/# locale
LANG=C.UTF-8
LANGUAGE=
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_PAPER="C.UTF-8"
LC_NAME="C.UTF-8"
LC_ADDRESS="C.UTF-8"
LC_TELEPHONE="C.UTF-8"
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=
#输入中文
root@6900b666a425:/# 好回到
注意:这样修改只是临时修改。要永久修改,需要在创建容器时在dockerfile中设置。 K8s进入pod不能输入中文 也可用此方法解决。