docker中文乱码

This commit is contained in:
2023-08-09 12:38:42 +08:00
parent 20430d9466
commit 284eca2520
4 changed files with 48 additions and 0 deletions

BIN
docker/image-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
docker/image-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
docker/image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

48
docker/setFonts.md Normal file
View File

@ -0,0 +1,48 @@
<h1>解决docker中文乱码</h1>
## 构建镜像
1. 编写Dockerfile
```Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /app #容器内的工作目录
EXPOSE 80 #容器监听的端口
ADD /Fonts/* /usr/share/fonts/ #中文字体
ENV LANG=C.UTF-8 #容器默认编码
ENTRYPOINT ["dotnet","RapidApp.Api.dll"]
```
2. 构建命令
```cmd
docker build -t [imagesName] -f Dockerfile .
```
ps:命令要在Dockerfile在的目录下执行
## 添加容器
![Alt text](image.png)
## 查看容器字体
1. 进入容器
```cmd
docker exec -it [containerName] bash
```
![Alt text](image-1.png)
2. 查看字体
* fc-list :查看所有字体
* fc -list:lang-zh:查看中文字体
![Alt text](image-2.png)
3. 命令不起作用
如果出现以下信息
```cmd
bash: fc-list: command not found
```
解决:
```cmd
apt-get update
apt-get upgrade
apt-get install fontconfig
```