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

Web design tips on form input boxes

This article lists some tips and codes about form...

Records of using ssh commands on Windows 8

1. Open the virtual machine and git bash window a...

Introduction to 10 Hooks in React

Table of contents What is ReactHook? React curren...

Solution to the low writing efficiency of AIX mounted NFS

Services provided by NFS Mount: Enable the /usr/s...

You really need to understand the use of CSS variables var()

When a web project gets bigger and bigger, its CS...

Vue3 encapsulates the side navigation text skeleton effect component

Vue3 project encapsulation side navigation text s...

Detailed explanation of computed properties in Vue

Table of contents Interpolation Expressions metho...

mysql startup failure problem and scenario analysis

1. One-stop solution 1. Problem analysis and loca...

Two methods of implementing automatic paging in Vue page printing

This article example shares the specific code of ...

Example of setting up a whitelist in Nginx using the geo module

Original configuration: http { ...... limit_conn_...

Three ways to achieve background blur in CSS3 (summary)

1. Normal background blur Code: <Style> htm...

CSS controls the spacing between words through the letter-spacing property

letter-spacing property : Increase or decrease th...