简体   繁体   English

.Net 5 - 无法在 buster (Debian) 容器中启用全球化

[英].Net 5 - Cannot enable globalization in buster (Debian) container

I'm having the same problem as described in https://github.com/dotnet/dotnet-docker/issues/1483 but this time with mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim.我遇到了与https://github.com/dotnet/dotnet-docker/issues/1483中所述相同的问题,但这次是 mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim。

The problem问题

If a Console.WriteLine($"{251.97:c}") is executed the weird symbol appears instead of $ or €.如果执行Console.WriteLine($"{251.97:c}")会出现奇怪的符号,而不是 $ 或 €。

Steps to Reproduce重现步骤

This is my Dockerfile (took out dependcies copy for simplicity):这是我的 Dockerfile (为简单起见,取出了依赖副本):

FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base

# FastReports needs libdgiplus
RUN apt-get update && apt-get install -y libgdiplus

# Disable the invariant mode (set in base image)
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
ENV LC_ALL=es_ES.UTF-8 \
    LANG=es_ES.UTF-8        # I've tried also en_US

WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src

COPY ["MyProject.WebUI/MyProject.WebUI.csproj", "MyProject.WebUI/"]

RUN dotnet restore "MyProject.WebUI/MyProject.WebUI.csproj"
COPY . .
WORKDIR "/src/MyProject.WebUI"
RUN dotnet build "MyProject.WebUI.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyProject.WebUI.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyProject.WebUI.dll"]

Other Information其他信息

Output: 251,97 ¤ Output: 251,97 ¤

Expected: 251,97 €预计:251,97 欧元

Output of docker version docker docker version的Output

Client: Docker Engine - Community
 Cloud integration: 1.0.4
 Version:           20.10.0
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        7287ab3
 Built:             Tue Dec  8 18:55:31 2020
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.0
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       eeddea2
  Built:            Tue Dec  8 18:58:04 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker info Output 的docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.4.2-docker)
  scan: Docker Scan (Docker Inc., v0.5.0)

Server:
 Containers: 19
  Running: 1
  Paused: 0
  Stopped: 18
 Images: 186
 Server Version: 20.10.0
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc version: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.19.128-microsoft-standard
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 6.068GiB
 Name: docker-desktop
 ID: G6ZX:FURA:YMMU:OQK7:FFVP:F6UD:SEQR:KJNC:CTHW:TVJY:KNJ6:Z5P7
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 56
  Goroutines: 62
  System Time: 2020-12-29T05:43:26.9357651Z
  EventsListeners: 4
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

WARNING: No blkio weight support
WARNING: No blkio weight_device support
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

I've tried to solve it by setting the LC_ALL and LANG variables but it seems that does't work.我试图通过设置LC_ALLLANG变量来解决它,但似乎不起作用。

Thanks谢谢

Ok, it seems it was my fault.好吧,看来是我的错。

I've removed images and containers and it worked as expected.我已经删除了图像和容器,它按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM