Docker solves the problem that the terminal cannot input Chinese

Docker solves the problem that the terminal cannot input Chinese

Preface:

One day, I built a MySQL service in Docker and found that I could not enter Chinese characters in the MySQL command line. Chinese characters were also replaced by ?. I initially thought it was a problem with the MySQL character set. After checking, the problem was not solved. I exited the container terminal and found that I could not enter Chinese characters either. I inferred that there was a problem with the system character set. The solution process is recorded as follows:

Before resolution:

# Enter the container to view the character set [root@master2 ~]# docker exec -it b18f56aa1e15 /bin/bash
root@b18f56aa1e15:/# 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=
# View the character sets supported by the container root@b18f56aa1e15:/# locale -a
C
C.UTF-8
POSIX

Cannot input Chinese characters: The system uses the POSIX character set, which does not support Chinese characters, while C.UTF-8 does. The problem can be solved by changing the system's environment LANG to "C.UTF-8" format.

Just enter the container like this to input Chinese: docker exec -it b18f56aa1e15 env LANG=C.UTF-8 /bin/bash

[root@master2 ~]# docker exec -it b18f56aa1e15 env LANG=C.UTF-8 /bin/bash
root@b18f56aa1e15:/# Helloroot@b18f56aa1e15:/# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 80
Server version: 5.7.17-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> Hello

Notice:

This modification is only temporary. To make the change permanent, you need to set it in the Dockerfile when you create the container.
This method can also be used to solve the problem that Chinese characters cannot be entered when entering the pod in K8s.

The above is the details of how Docker solves the problem of being unable to input Chinese characters in the terminal. For more information about Docker solving the problem of being unable to input Chinese characters, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Use of environment variables in Docker and solutions to common problems
  • Docker exposes port 2375, causing server attacks and solutions
  • Install Jenkins with Docker and solve the problem of initial plugin installation failure
  • Solve the problem that the docker container cannot ping the external network
  • When setting up Jenkins in Docker environment, the console log shows garbled Chinese characters when building tasks
  • Solution to the problem that docker logs cannot be retrieved
  • Share the problem of Ubuntu 19 not being able to install docker source
  • Docker FAQ

<<:  JQuery implements hiding and displaying animation effects

>>:  How to set process.env.NODE_ENV production environment mode

Recommend

Vue calls the computer camera to realize the photo function

This article example shares the specific code of ...

Use of Linux cal command

1. Command Introduction The cal (calendar) comman...

How to store text and pictures in MySQL

Large Text Data Types in Oracle Clob long text ty...

MySQL 8.0.12 installation and configuration method graphic tutorial (windows10)

This article records the installation graphic tut...

Docker configuration Alibaba Cloud image acceleration pull implementation

Today I used docker to pull the image, but the sp...

How to decrypt Linux version information

Displaying and interpreting information about you...

Try Docker+Nginx to deploy single page application method

From development to deployment, do it yourself Wh...

How to mount a new disk on a Linux cloud server

background A new server was added in the company,...

Detailed explanation of MySQL data rows and row overflow mechanism

1. What are the formats of lines? You can see you...

10 HTML table-related tags

In fact many people will say “I’ve seen that table...

Use the sed command to modify the kv configuration file in Linux

sed is a character stream editor under Unix, that...

Example of how to implement value transfer between WeChat mini program pages

Passing values ​​between mini program pages Good ...