Solution to Chinese garbled characters in docker web: 1. Use locale to check the character set used by the system of the current container; 2. Use "locale -a" to check the character set supported by the system of the current container; 3. Modify "/etc/profile" and add the system variable LANG.

The operating environment of this tutorial: Windows 7 system, Docker version 20.10.11, Dell G3 computer.
docker web What should I do if the Chinese characters are garbled?
Solving the problem of garbled Chinese characters in docker containers
In the command line, when inputting Chinese characters, garbled characters or typing errors occur:
Here I want to input: "Chinese", but garbled characters appear.

And, I have created the image before and generated the container through the image.
1. Use locale to view the character set used by the system of the current container.
2. Use locale -a to check the character sets supported by the system of the current container.
3. In some blogs, it is recommended to modify /etc/profile and add system variables LANG, etc.
1)/etc/profile: This file sets environment information for each user of the system. When the user logs in for the first time, this file is executed.
And from /etc/profile Collect shell settings from the configuration file in the .d directory.
Note: Here we set global variables that can be used by all users.
2)/etc/bashrc: Execute this file for each user running the bash shell. When the bash shell is opened, this file is read.
But it can be seen that /etc/profile is only executed when the user logs in for the first time. So after you modify the file and docker commit, running the container again with the updated version will not take effect.
So, here, I modify /etc/bashrc to update the system character set variable:
export LANG="C.UTF-8" export LANGUAGE="C.UTF-8" export LC_ALL="C.UTF-8"
After modification, remember to take effect:
source /etc/bash.bashrc
View through locale again Whether the system character set has been updated:
root@7bfce1075a4b:/workspace# locale LANG=C.UTF-8 LANGUAGE=C.UTF-8 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=C.UTF-8
Finally, you can see that you can enter Chinese on the command line normally:
root@7bfce1075a4b:/workspace# 中文
Finally, don’t forget to submit the image update: you can choose to overwrite the current Mirror, as long as the warehouse name: label name is the same as what you want to overwrite
docker commit -m="run command" -a="wkn" 7bfce1075a4b wkn/pattern-ai:torch_1.11.0_v
Run a new container through the updated mirror again:
wkn@MightyDragon:~$ docker commit -m="run command" -a="wkn" 7bfce1075a4b wkn/pattern-ai:torch_1.11.0_v1 sha256:18b066686fe87306bb1b09e2e98c89af04a23ec6054edbf3cc73bd1dc72826a7 wkn@MightyDragon:~$ docker run -v /home/wkn:/home/wkn -it --gpus '"device=0,1"' 18b066686fe8 root@05c9c8706296:/workspace# 中文
It can be seen that Chinese can be input normally~
Recommended learning: "docker video tutorial"
The above is the detailed content of What to do if docker web Chinese garbled characters. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function





